vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Querying db for missing table row. (https://vborg.vbsupport.ru/showthread.php?t=69786)

Jolten 09-23-2004 03:58 PM

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.

Tekton 09-24-2004 03:19 AM

Could you do an IF and see if the value is == null or == ""?

Jolten 09-24-2004 03:25 AM

I don't know. Can i?

Tekton 09-24-2004 03:34 AM

Have you tried?? :)
PHP Code:

if ($whatever == null || $whatever == ""){




Jolten 10-30-2004 07:27 PM

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.

Jolten 10-30-2004 10:53 PM

oop.. nevermind I got it sorted. Queried for existing then wrote a couple php conditionals.

Thanks for the help Tekton


All times are GMT. The time now is 08:58 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00978 seconds
  • Memory Usage 1,716KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete