What would be the correct format for this? I would like to see if tid IS NULL and if so leave out the last WHERE statement and not get anything from tsms table.
- $sql = "SELECT * FROM users INNER JOIN tsms WHERE id='".$_REQUEST[2]."' ".
-
"IF(tid NOT NULL) THEN AND tsms.uid=tid END IF";
Hi,
i think, u r trying to join the 2 table to get the data from the tables when the user id is available in both tables. But the above join syntax is wrong. Check with the following query, it will help for ur requirement.
-
SELECT usr.*
-
FROM users usr
-
INNER JOIN tsms ts ON usr.id = ts.uid
-
WHERE usr.id = <$_REQUEST[2]>;
Before try with the table join, you must learn the syntax of the table join.
http://dev.mysql.com/doc/refman/5.0/en/join.html
check the above link
Regards,
S.Ashokkumar
Please enclose your posted code in [code] tags (See
How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use [code] tags in future.
MODERATOR