Monday, 15 April 2013

Sql Join Table , Part Of Select Data Condition -



Sql Join Table , Part Of Select Data Condition -

i have 2 table table , table b.

table contain id, number, time , value1

table b contain id, data, value2

example of record on table a: id number tried value1 ------- ---------- --------- --------- 1 123 23 5 2 124 23 6 3 1254 23 7 illustration of record on table b: id info value2 ------ --------- ------- 1 123,23 6 2 122,21 5 3 1254,23 7

my purpose add together value 1 , value 2 bring together status of table b info table number , tried match record.

example : id (value1 + value2) ------- ----------------- 1 11 3 14

my query:

select a.id , a.value1+ b.value2 bring together b on substring(b.data,1,3) = a.number , substring(b.data,5,2) = a.tried

i had tried substring value of info record length different compare on id 1 , 3 , current of query result show id 1. there other way bring together 1 column field split 2 kind of value take out ',' bring together 2 field on table a?

check if query help, in oracle

select a.id , (a.value1+ b.value2) a, b a.id = b.id , b.data = (a.number || ',' || a.tried);

edit: based on @joachim isaksson suggestion:

select a.id ,b.id (a.value1+ b.value2) a, b b.data = (a.number || ',' || a.tried);

sql join

No comments:

Post a Comment