简体   繁体   English

Sqlite选择值作为其他表的id

[英]Sqlite select value as id to other table

I am working with SqLite, and I need connect table A with table B where the key is guid written as ["guid"] (TEXT).我正在使用 Sqlite,我需要将表 A 与表 B 连接起来,其中键的guid写为 ["guid"] (TEXT)。 How do I accomplish that?我如何做到这一点? (Should I use a substring value?) (我应该使用子字符串值吗?)

Table A表A

|name| value    
|a   | ["13889483-d92a-483e-9e16-471cb22b82a3","a7ced9c5-e7bc-4214-be77-a26d8f86844b"]

Table B表B

| name                                 | value |
|13889483-d92a-483e-9e16-471cb22b82a3  | abc

You need to fix your table A so it is in First Normal Form :您需要修复表 A 使其处于第一范式

Name  Value
a     13889483-d92a-483e-9e16-471cb22b82a3
a     a7ced9c5-e7bc-4214-be77-a26d8f86844b

Then you can connect the tables using a SQL join:然后您可以使用 SQL 连接连接表:

SELECT B.* FROM A
JOIN B ON B.Name = A.Value
WHERE A.Name = 'a'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当值不在另一个表上时选择SQLite - SQLite Select when value is not on another table JOOQ:select 其他表中不存在 ID 的所有表条目 - JOOQ : select all table entries where ID not present in other table 如何通过知道ID和列来获取特定表字段的值?(SQLite) - How to get the value of a specific table field by knowing the id and the column?(SQLite) Android值到Sqlite表 - Android value to Sqlite table 引起原因:android.database.sqlite.SQLiteException:否这样的表:food(代码1 SQLITE_ERROR):,同时编译:SELECT * FROM food order by id asc 1 - Caused by: android.database.sqlite.SQLiteException: no such table: food (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM food order by id asc 1 引起原因:android.database.sqlite.SQLiteException:否这样的表:food(代码1 SQLITE_ERROR):,同时编译:SELECT * FROM food order by id asc 2 - Caused by: android.database.sqlite.SQLiteException: no such table: food (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM food order by id asc 2 在 sqlite 的中间表中插入值 - Inserting value in middle table in sqlite 在sqlite表中找到一个名称并返回ID? - find a name in a sqlite table and return the id? android.database.sqlite.SQLiteException:否这样的表:USER_DATA_TABLE(代码1):,而在编译时:SELECT * FROM USER_DATA_TABLE WHERE id =? 限制1 - android.database.sqlite.SQLiteException: no such table: USER_DATA_TABLE (code 1): , while compiling: SELECT * FROM USER_DATA_TABLE WHERE id=? LIMIT 1 SELECT total(value)的SQLite和性能问题 - SQLite and performance issue with SELECT total(value)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM