Problem query
Posted: Thu Dec 23, 2004 2:29 am
Hi all,
I really dont know why I am having so much trouble with queries of late. I guess I am just asking more of a query now than I once did.
Anyhow, I have two tables which track data on my sites users. There are two types of user, a vendor and a standard user. All login information and basic account info is stored in a table called tbl_user_auth and extended info for vendors is stored in tbl_vendor.
tbl_user_auth has a primary key called user_pk, while tbl_vendor has one called vend_pk and links across to user_pk with a column called user_id
When a user logs on I pull up their record and load a few values to a session variable.
What I am wanting to do is to query the users vendor ID should there happen to be an entry for it in the other table.
The problem I am having is that it works fine if the user has a vendor record, but if there is not one present, it returns zero results.
Is there a way to return values if there is an entry in the second table or not, or should I just call this with a second query?
Thanks for any feedback you can give.
I really dont know why I am having so much trouble with queries of late. I guess I am just asking more of a query now than I once did.
Anyhow, I have two tables which track data on my sites users. There are two types of user, a vendor and a standard user. All login information and basic account info is stored in a table called tbl_user_auth and extended info for vendors is stored in tbl_vendor.
tbl_user_auth has a primary key called user_pk, while tbl_vendor has one called vend_pk and links across to user_pk with a column called user_id
When a user logs on I pull up their record and load a few values to a session variable.
What I am wanting to do is to query the users vendor ID should there happen to be an entry for it in the other table.
The problem I am having is that it works fine if the user has a vendor record, but if there is not one present, it returns zero results.
Code: Select all
SELECT
`tbl_user_auth`.`USER_PK`,
`tbl_vendor`.`VENDOR_PK`
FROM
`tbl_user_auth`,
`tbl_vendor`
WHERE
(`tbl_vendor`.`USER_ID` = `tbl_user_auth`.`USER_PK` )Thanks for any feedback you can give.