How to get the name in a mysql view?


(Erandbraho) #1

Hi all,

I have a mysql query (UNION of 4 tables). I display this view to the user. How do I display the name and not the ID to the user? I mean this view has no "relations" (fk or whatsoever) so how do I access the name? Eg:

TableA

-idA

-name

-a1

-a2

TableB

-id

-idA

-b1

-b2

-common

TableC

-id

-idA

-c1

-c2

-common

In my view lets say:

SELECT idA FROM TableB WHERE common=0;

UNION

SELECT idA FROM TableC WHERE common=0;

When I show this view to the user, how do I display "name" from tableA (not idA)?


(Oligalma) #2

http://dev.mysql.com/doc/refman/5.0/en/union.html