SELECT * FROM table1, table2 WHERE table1.user_id = table2.id AND table1.content = news AND table1.content_id = 1
that wont work. cant u have two "AND" in a sql statement??
//Tomek
SELECT * FROM table1, table2 WHERE table1.user_id = table2.id AND table1.content = news AND table1.content_id = 1
that wont work. cant u have two "AND" in a sql statement??
//Tomek
news
is what? Some sort of parameter? Value of the field? A word which should occur in the field? Most likely your syntax is wrong, see W3Schools WHERE and W3Schools AND/OR operators pages for more information.
I would STRONGLY recommend to use the proper JOIN syntax:
select * from table1 inner join table2 on table1.user_id = table2.id ......
what datatypes is "table1.content" ?
You can most definitely have a lot more than just 2 AND statements in a SQL query - any database that really support any of the SQL-xx standards will support this...
Marc
let me rewrite that for you with a JOIN statement since it is not 1995 anymore, you also need quotes around news
SELECT * FROM table1 t1
inner join table2 t2 on t1.user_id = t2.id
AND t1.content = 'news'
AND t1.content_id = 1
I liked cmartin's response. Also, you can use more than one AND, if needed.