The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Querying db for missing table row.
Hi,
I want to query two tables in my database. Table 1 is a list of images and artists (image #, artistuser, imagetitle). When a user comments on one of these images Table 2 is updated with the username and comment (Image #, commentuser, comment). I'd like to write a loop to display to the user every image in Table 1 that does not have a corresponding comment row in Table 2. I can work out the loop but I'm lost on writing the sql query where a row is nonexistant. Basically I needsomething like: where table1.image# = table2.image# and $bbuserinfo[username] does not exist in table2.commentuser Is this possible? Any help would be appreciated. |
#2
|
|||
|
|||
Could you do an IF and see if the value is == null or == ""?
|
#3
|
|||
|
|||
I don't know. Can i?
|
#4
|
|||
|
|||
Have you tried??
PHP Code:
|
#5
|
|||
|
|||
Thanks Tekton
Here's the run down. A user rates an item and when they rate this item, the item #, rating, and username are placed into the database. What I need to to write an sql query that displays all items the user has not rated, therefore I need a query that basically states... table.userfield does not contain $bbuserinfo[username]. I can get table.userfield = '$bbuserinfo[username]' to display all the items a user has rated. What I'm having trouble with is getting items the user has NOT rated. using table.userfield != '$bbuserinfo[username]' results in all items showing and in fact all items showing twice for some reason. Including those items the user has rated. I don't know if I can use if conditionals within an sql query and I'm not certain how to right the query if I can use conditionals. |
#6
|
|||
|
|||
oop.. nevermind I got it sorted. Queried for existing then wrote a couple php conditionals.
Thanks for the help Tekton |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|