Simplify Query

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
WanamakerStudios
Forum Commoner
Posts: 65
Joined: Thu Nov 30, 2006 7:35 am

Simplify Query

Post by WanamakerStudios »

Is there a way to simplify this part of my query?

Code: Select all

LEFT JOIN `options` o1
		ON o1.CIDOPTI = v.O1
		LEFT JOIN `options` o2
		ON o2.CIDOPTI = v.O2
		LEFT JOIN `options` o3
		ON o3.CIDOPTI = v.O3
		LEFT JOIN `options` o4
		ON o4.CIDOPTI = v.O4	
		LEFT JOIN `options` o5
		ON o5.CIDOPTI = v.O5
		LEFT JOIN `options` o6
		ON o6.CIDOPTI = v.O6
		LEFT JOIN `options` o7
		ON o7.CIDOPTI = v.O7
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

possibly with IN()
WanamakerStudios
Forum Commoner
Posts: 65
Joined: Thu Nov 30, 2006 7:35 am

Post by WanamakerStudios »

Would you be able to provide an example?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If memory serves, you are able to reference fields within the IN(). That really shouldn't need an example.
WanamakerStudios
Forum Commoner
Posts: 65
Joined: Thu Nov 30, 2006 7:35 am

Post by WanamakerStudios »

I know how to reference IN() in the JOINs ... but am not quite sure how to do it with multiple fields in one table against one field in a second table ...
Post Reply