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

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.