php - How to not obtain any row if there is nothing in both tables? -
I have a profile.php file on our site that generates a specific profile from a database using SQL queries . Choose
Select Registered, date-format ('00 -00-0000 00: 00 ','% E 'as use, U.Mail, UACAC, date-format (U.GURTDD,'% e.% C.YY)) % C.% Y ') as' Last_Visit', as Posts from Users U as Count (PID), Yu ou U on posts. Username =? And p.post_creator = u.id;
And below I test that if the user is present with all its data, then using the mysql_num_rows ()
function (please read PHP's MYSQL extension Avoid comments about using, I only get the problem
, because if I give unknown code to I still wanted to get empty result set. I got the Is there something cleaner to do? is? When specifying such rows to filter, WHERE
section (instead of user icon, instead of question mark) Instead of getting blank results - the finished MySQL database Gives me a line, which contains most code fields NULL
s, last_visit >> with the expected
0 0000
and posts < / Code> with
0
(zero).
It is very beautiful, but I do not want to be empty, but in some specific areas (such as u.username
) they are empty / NULL is not or not, in my PHP script, because it is a very dirty method to check.
JOIN , then
WHERE (...) and u.id is not empty
but both do not work (no behavior). Then I tried the hasing u.id is not empty
and SELECT (...)
after adding a column to the expression, it works.
I knew that after selecting the hosting
clause, the result-set is for filtering and I'm asking you: SELECT
(Or is this a good practice? I have not received a lot of answers on my question.)
believe me Your problem is arising due to some weird behavior of some groups with an array, an aggregation query always returns a line, even if all the rows are filtered . A group query with group
can return 0 rows. So, I think you just select a group
:
User, UEmail, U.X., date format (URIRADAT) registered as `last-visit`, date-format ('00 -00-0000 00:00 ','% e.c. c. Yi '), as calculated (PIID) as a' post 'from users, you are included in post p on p.post_creator = u.id where U. username =? Group by U.username;
Note that I have changed the query to use the clear join
syntax with the condition included in the section on
The obvious connect is more powerful than the implicit connect.
Comments
Post a Comment