Error FIX: Column Name Appears More Than Once In Result Column

Comments 3 Standard

Okay, so I kept getting this error and it finally dawned on me that it means exactly what it says, lol. I was trying to run a stored procedure and had selected one field two times like this:

SELECT  M.name, A.address, A.phone, M.email, M.name FROM members M inner join address A on M.id = A.id;

I selected name twice without renaming it and this is what caused the error. Silly me.

Advertisements

3 thoughts on “Error FIX: Column Name Appears More Than Once In Result Column

  1. Sometimes it also happens if you’re joining two tables that have the same column and you’re not running a natural join. For instance if you did something like:

    SELECT A.*, B.* FROM address A LEFT OUTER JOIN badaddress B

    If A and B both have a field with the same name you’ll have the same problem.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s