检查表名以更新数据(sqlite)

时间:2009-10-24 10:10:45

标签: sql sqlite

我有两张这样的表

  • table_CN(_id,姓名,电话,收藏,标题)
  • table_EN(_id,姓名,电话,收藏)

然后我从两个表中选择_id值

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

之后我不知道如何确定更新数据的表名,我可以用SQL查询吗?我在这里很困惑!

1 个答案:

答案 0 :(得分:0)

您可以手动将表名添加到结果中:

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'

顺便说一下,有没有理由不使用_id, lang, name, phone, favorite, title, PRIMARY KEY (_id, lang)这样的表格?