SQLite combo-request with concatenating results
I use SQLite, and i want to create request for such option.
I have two tables A, B.
In A records contain field id
with integers, and some field with string, for example name
In table B i have columns with names:
number A<name1> A<name2> A<name3>...
I need to get number
from table B, where field A<nameK>
equal to some value, where is name
for id
in table A.
So i know id
for A and i want to know number
from B.
So i have 2 requests.
SELECT name as my_name FROM A WHERE id=<value>;
And after this i want something like that:
SELECT number FROM B WHERE A||my_name = <value>;
( || - i mean concatenacting of strings), but it's not work:(
Update - example of tables structures:
A:
id name
1 a
2 b
3 c
B:
num开发者_高级运维ber Aa Ab Ac
10 1 2 3
11 4 5 6
12 7 8 9
So for example id=2
, value in B=5
, name=b
, column name in B is Ab
. Result number=11
id=3, value=6
. Result number=11
id=3, value=4
. Result no result
Without more information about your table structure, I highly assume that it is flawed. Just save A<name>
's number
in individual rows, if necessary with an extra column for certain flags.
精彩评论