View Full Version : MySQL Syntax and Priority
03-21-2007, 01:41 AM
I am not writing correct syntax so dont flame me about that... I simply do not know the syntax for this situation so instead i am writing the priority.
SELECT * FROM table WHERE (condition1 AND contition2) OR (condition3 AND condition4)
This is to relate two other tables and sometimes your id is in condition 1 and sometimes its in condition 3.... I want to prevent overlap between like IDs in the two tables...
Is there a syntax to do that like above?
03-21-2007, 02:00 AM
your explanation really isn't clear. can you show your actual table layouts, sample data and the output you are trying to achieve? that might make what you are asking clearer.
03-21-2007, 02:34 AM
Its is a relationship system between user & user, user & vendor, vendor & vendor
lets say i am a user and I wanted to find all instances of myself in the db
I would need to look for myself
WHERE USER_ID = MY ID AND USER_TYPE = MY TYPE
but I would also need to see myself in the FRIEND_ID field WHERE RELATIONSHIP is MY_TYPE
(In some cases you are someones friend, and in some cases someone is your friend, i want both)
Because you may have duplicate id's in the user & vendor table...
SELECT * FROM friends WHERE (USER_ID = ME AND USER_TYPE= MY TYPE) OR ( FRIEND_ID = ME AND RELATIONSHIP = MY TYPE )...
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.