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
https://forums.phpfreaks.com/topic/31318-solved-select-love-syntax/
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
[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...

Archived

This topic is now archived and is closed to further replies.

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