vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Data Base Query? (https://vborg.vbsupport.ru/showthread.php?t=225517)

RichieBoy67 10-18-2009 11:19 PM

Data Base Query?
 
Hello,

I have a list of data to pull and I have the query for most of the data as you can see. I need to add e-mail addresses and usernames to this somehow and I am having a hard time getting this to work.

Here is what I have so far.....

PHP Code:

SELECT userfield.userid
     
userfield.field19
     
userfield.field20
     
userfield.field12
     
userfield.field13
     
userfield.field18
     
userfield.field14
     
userfield.field15
     
userfield.field16
    FROM userfield
INNER
  JOIN user
    ON user
.userid userfield.userid
 WHERE user
.usergroupid 15 

I just need to add e-mail and usernames.... any help would be great..

Thanks

Lynne 10-19-2009 12:07 AM

user.username and user.email are the fields you would add to the SELECT statement.

RichieBoy67 10-19-2009 12:11 AM

I don't know why but that wasn't working. I must be doing something wrong. I figured I was missing something..

Thanks so much Lynne, I will try again and figure out what I was doing wrong...

Thanks Lynne... Just me being stupid again..

PHP Code:

SELECT ,user.username
     
user.email
     
userfield.userid
     
userfield.field19
     
userfield.field20
     
userfield.field12
     
userfield.field13
     
userfield.field18
     
userfield.field14
     
userfield.field15
     
userfield.field16
    FROM userfield
INNER
  JOIN user
    ON user
.userid userfield.userid
 WHERE user
.usergroupid 15 

I see the problem now.. It is the "," on the first line... I have wasted the last 3 hours because of one ","!!! Who knows how much longer I would have spent on this if you didn't rescue me.

Thank you very much..

Lynne 10-19-2009 02:25 AM

Hehe. Usually I put the commas at the end of the line. It just makes it easier for me that way.

Adrian Schneider 10-20-2009 07:08 PM

It's good practice to put commas before on SQL, as it's much easier to see them this way.

Code:

SELECT user.username
    , user.email
    , userfield.userid
    , userfield.field19
    , userfield.field20
    , userfield.field12
    , userfield.field13
    , userfield.field18
    , userfield.field14
    , userfield.field15
    , userfield.field16
  FROM userfield
INNER
  JOIN user
    ON user.userid = userfield.userid
 WHERE user.usergroupid = 15;

See how everything is lined up and super easy to read? :)

Lynne 10-20-2009 08:09 PM

Quote:

Originally Posted by SirAdrian (Post 1902791)
It's good practice to put commas before on SQL, as it's much easier to see them this way.

See how everything is lined up and super easy to read? :)

Yeah, I see that, but.... but..... but.... I'd have to retrain myself!!!!!

:)


All times are GMT. The time now is 12:45 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.01031 seconds
  • Memory Usage 1,734KB
  • 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_code_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_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