PDA

View Full Version : Data Base Query?


RichieBoy67
10-18-2009, 11:19 PM
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.....

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..

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.

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
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!!!!!

:)