Cheers
I would really apprecite if anyone could make a comment on this...
what i wanna know is...
there are two tables, called 'A' and 'B' with identical structures...
is it possible to Perform the following in a single SQL ...
* If A->Field1 = B->Field1 then A->Field2 + b->Field2
* Records of table 'A' which not in table 'B' and
* Records of table 'B' which not in table 'A'
ThanksHi man!
UPDATE A
SET A.Field2=A.Field2+b
FROM A inner Join B On A.Filed1=B.Filed1
Good Luck!|||Cheers Jekker
Thanks a lot for your effort...
the code which u posted could be useful and will perform,
* If Records in table 'A'->field1 = table 'B'->field1 then
'A'->field2 + 'B'->field2
* Records in table 'A' but not in table 'B' (Unique to 'A')
# But records in table 'B' which isnt in table 'A' wont get inserted to the table 'A' !
What i need is just a SQL to extract data and not to update...
anyway thanks again for your effort and for your time.
take care|||Sorry I was wrong.
I try again!
* If A->Field1 = B->Field1 then A->Field2 + b->Field2
SELECT (A.Field2+b) as NewField
FROM A Inner Join B ON A.Field1=B.Field1
* Records of table 'A' which not in table 'B' and
SELECT A.* FROM
A LEFT JOIN B ON A.Field1=B.Field1
WHERE B.Field1 Is Null
* Records of table 'B' which not in table 'A'
SELECT B.* FROM
A Right Join B ON A.Field1=B.Field1
WHERE A.Field1 Is Null
Check it|||Is it Possible to COMBINE the 3 SQLs which you have posted?
what i need is to merge it into one SQL
Thanks|||mmm
You can use Union.
SELECT (A.Field2+b) as NewField
FROM A Inner Join B ON A.Field1=B.Field1
UNION
--Records of table 'A' which not in table 'B' and
SELECT A.Field1 as NewField FROM
A LEFT JOIN B ON A.Field1=B.Field1
WHERE B.Field1 Is Null
UNION
-- Records of table 'B' which not in table 'A'
SELECT B.Field1 as NewField FROM
A Right Join B ON A.Field1=B.Field1
WHERE A.Field1 Is Null
But you should know, that UNION work like DISTINCT.
Showing posts with label apprecite. Show all posts
Showing posts with label apprecite. Show all posts
Subscribe to:
Posts (Atom)