I have a php page with a variable $lid, and a user with vairable $uid… I need to select some data from 2 tables to fill out the page.
Table 1 Table 2
¦----------¦----------¦ ¦----------¦----------¦----------¦
¦ qid ¦ lid ¦ ¦ owner ¦ qid ¦timestamp ¦
¦----------¦----------¦ ¦----------¦----------¦----------¦
I need to write an SQL statement that gets everything from table 2 where the owner = $uid if the qid is not already listed in table1 with the current pages’ $lid.
I tried
SELECT * FROM table_two WHERE qid != (SELECT qid FROM table_one WHERE lid = " . $lid .") AND owner = " . $uid . ";
But had no joy
Any ideas?
This would work:
This will probably perform better: