tags:

views:

35

answers:

1

I have two table like this

  • table_CN (_id, name, phone, favorite, title)
  • table_EN (_id, name, phone, favorite)

Then I select _id value from two table

SELECT _id, name, phone, favorite FROM table_CN where _id='15'UNION SELECT _id, name, phone, favorite FROM table_EN where _id='15'

After that I don't know how to determine which table name to update data, can I do that with SQL query? I'm confusing here!

A: 

You can add the table name to the result manually:

SELECT _id, name, phone, favorite, 'table_CN' AS table_name FROM table_CN where _id='15' UNION
SELECT _id, name, phone, favorite, 'table_EN' AS table_name FROM table_EN where _id='15'

Btw, is there a reason to not use a table like _id, lang, name, phone, favorite, title, PRIMARY KEY (_id, lang)?

Lukáš Lalinský
I can get it! thanks!
Dennie