开发者

Check table name to update data (sqlite)

开发者 https://www.devze.com 2022-12-09 21:21 出处:网络
I have two table like this table_CN (_id, name, phone, favorite, title) table_EN (_id, name, phone, favorite)

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 dete开发者_如何学Gormine which table name to update data, can I do that with SQL query? I'm confusing here!


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)?

0

精彩评论

暂无评论...
验证码 换一张
取 消