Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-18-2009, 10:19 PM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
  #2  
Old 10-18-2009, 11:07 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

user.username and user.email are the fields you would add to the SELECT statement.
Reply With Quote
  #3  
Old 10-18-2009, 11:11 PM
RichieBoy67's Avatar
RichieBoy67 RichieBoy67 is offline
 
Join Date: Apr 2004
Location: CT - Down in a hole..
Posts: 3,057
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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..
Reply With Quote
  #4  
Old 10-19-2009, 01:25 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hehe. Usually I put the commas at the end of the line. It just makes it easier for me that way.
Reply With Quote
  #5  
Old 10-20-2009, 06:08 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #6  
Old 10-20-2009, 07:09 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SirAdrian View Post
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!!!!!

Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:14 PM.


Powered by vBulletin® Version 3.9.0
Copyright ©2000 - 2017, vBulletin Solutions Inc.