A
A
avada kedavra2015-04-22 20:24:07
SQL
avada kedavra, 2015-04-22 20:24:07

Exclude fields in query with JOIN?

I suppose this is a trivial question, but for some reason I can not find a clear example.
There is a table, say users, with 30 fields, including a city_id foreign key associated with the cities table in which there are only two fields - id and name
. You need to perform a SELECT ... JOIN so that
users.city_id and cities.id
- got cities.name, but with a different field name, for example city, because name will be duplicated
- (not archival, but just in case) you need to exclude one field from users, but not by listing the remaining 29 and not assigning NULL to it

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
IceJOKER, 2015-04-22
@kedavra

If the field names are duplicated, then you can assign an alias, for example - It is users.name as user_name, cities.name as city_name
necessary to enumerate, otherwise another approach is not recommended.
stackoverflow.com/questions/729197/sql-exclude-ac...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question