What is wrong with my SQL query?

hi guys, I’m trying to get it work but there is no data appearing …


SELECT *
FROM lists INNER JOIN domains
ON lists.domainID=domains.domainID
INNER JOIN keywords
ON lists.keywordID=keywords.keywordID;

data in lists table is as follows…


-------------------------------------------------+
| listID | domainID | keywordID | domain_name     
+--------+----------+-----------+-------------
|      2 |        1 |      NULL | top 20 domains  |
|      3 |     NULL |         8 | top 20 keywords |
|      4 |        1 |      NULL | lsit naem here  |
+--------+----------+-----------+---------------


Query shows me nothing …

Because non of the rows in the lists table has corresponding data in both other tables, right?
Try using LEFT OUTER JOINs instead of INNER JOINs.

exactly, it solved the problem.

is Inner join is alternate of Where Clause ?

I’m not sure I understand your question, but I’d say no :slight_smile:

Read more about joins here: http://dev.mysql.com/doc/refman/5.1/en/join.html

http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html

That should shed some light on joins.