Re: How to query this table
Like this?
SELECT userId
FROM userProfileData
WHERE fieldName = 'emailSubscribe'
AND fieldData = 'yes'
This would give you back a list of userId that wanted to subscribe. If you're running mySQL 4.1, then you could bury this in a subquery:
SELECT fieldData
FROM userProfileData
WHERE fieldName = 'email'
AND userId IN (SELECT userId
FROM userProfileData
WHERE fieldName = 'emailSubscribe'
AND fieldData = 'yes')
If you're not running 4.1, then you should be able to join the table on itself, although this would not be a good idea if the table is large:
SELECT u1.fieldData
FROM userProfileData u1, userProfileData u2
WHERE u1.userId = u2.userId
AND u1.fieldName = 'email'
AND u2.fieldName = 'emailSubscribe'
AND u2.fieldData = 'yes'
Subject
Written By
Posted
Re: How to query this table
March 25, 2005 07:07PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.