Jump to content

howto - left join on a column name?


ryel01

Recommended Posts

Hello!

 

Does anyone know if it's possible to perform a left join onto a column name?

 

ie. in the following sql I want paymentmethods.method to be used to match the "paymentsettings.column_name", instead of actually specifying "paymentsettings.column_name" directly.

 

So for an example of what I mean that doesn't work...

and paymentmethods.method = paymentsettings.(paymentmethods.method)

 

 

				left outer join
				paymentsettings
				on account.id = paymentsettings.aid
				and paymentmethods.method = paymentsettings.column_name

 

?

 

Regan

Link to comment
https://forums.phpfreaks.com/topic/226004-howto-left-join-on-a-column-name/
Share on other sites

  • 2 weeks later...

You might try explaining better what you're trying to do. 

 

In general, no, joins are based on values matching in particular columns.  There is no way for mysql to guess what column you want to join on or alter that on a row by row basis.  A lot of times when someone is looking for something like that it reflects that their database structure is not relational.

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.