Jump to content

[SOLVED] SELECT love Syntax...


arprilia

Recommended Posts

Need Help!!!

i would like to display records for people that loves 'A' and loves 'B'...
i'm having problem with this syntax...

SELECT * FROM loves WHERE loveID = 'A' AND loveID = 'B'


tried using the syntax below...

SELECT lovesFROM kemahiran
WHERE loveID IN ('A', 'B')

..but it returns anyone who loves 'A' or 'B'....
..instead i wanna display people who love both 'A' & 'B'...

please help....thanx in advance.....
Link to comment
Share on other sites

Oh, got ya.  Well looking at your query, it should only select people who love BOTH A and B.

I'm abit confused by your "SELECT loves FROM kemahiran" Used in this syntax your table name is kemahiran but I'm GUESSING that kemahiran is a user in the loves table?

I can only venture an educated guess w/o knowing how your db is setup. I'm guessing you have a users table, a loves table with a 1 to many relationship between the two.

So for user_id 134 you might have an entries in the loves table that look like so
[code]
id        user_id  love_code
355    134        A
356    134        B
357    134        F
[/code]

Is that's a poor educated guess, then tell us what your table structure is like
Link to comment
Share on other sites

[quote author=artacus link=topic=119339.msg488685#msg488685 date=1166596109]
Oh, got ya.  Well looking at your query, it should only select people who love BOTH A and B.

I'm abit confused by your "SELECT loves FROM kemahiran" Used in this syntax your table name is kemahiran but I'm GUESSING that kemahiran is a user in the loves table?

I can only venture an educated guess w/o knowing how your db is setup. I'm guessing you have a users table, a loves table with a 1 to many relationship between the two.

So for user_id 134 you might have an entries in the loves table that look like so
[code]
id        user_id  love_code
355    134        A
356    134        B
357    134        F
[/code]

Is that's a poor educated guess, then tell us what your table structure is like
[/quote]

you're right....

based on your 'poor educated guess'  ;) ...
there are 2 tables; user n love. altering your tbl above (if i may)

[code]
id        user_id  love_code
355    134        A
356    134        B
357    134        F
358    135        A
359    135        C
360    136        B
[/code]

i want to have user_id that have love_code A and B...
if i use OR it will return user_id 134, 135 and 136...
instead i want only user_id 134...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.