MySQL Forums
Forum List  »  GIS

Re: join on
Posted by: Jonathon Coombes
Date: October 16, 2012 05:34PM

Looking at your syntax:

SELECT * FROM Dammreg INNER JOIN Dammreg ON Dammreg.DNAMN LIKE CONCAT('%', Damm_vk.NAMN, '%');

and received the error message: #1066 - Not unique table/alias: 'Dammreg'.

The reason for this is that you are joining the table to itself, but don't specify aliases to distinguish different fields of the same names. Also, using a function within the join condition is bad. Instead try the following syntax:

SELECT *
FROM Dammreg AS d1
INNER JOIN Dammreg AS d2 ON (d1.DNAMN=d2.DNAMN)
WHERE d1.DNAMN LIKE '%Damm_vk.NAMN%');

Further details on table aliases are in the manual at:

http://dev.mysql.com/doc/refman/5.5/en/join.html

Options: ReplyQuote


Subject
Views
Written By
Posted
4169
September 14, 2012 03:52AM
Re: join on
2473
October 16, 2012 05:34PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.