I use vbRichClietn5.dll for Sqlite.
I just needed to update a table based on a condition met by a join to another table.
It didn't work.
Then I google searched and realized that somebody else had a similar problem, and the solution was quite strange:
https://stackoverflow.com/questions/...join-in-sqlite
Here is the solution:
I copied the same syntax for my own tables, and it works.
However, this is really unbelievable!
What if you want to update 5 columns instead of one!!!???
It will be something like this:
Well!!!
Do you think this makes sense!!!???
I know it works. No doubt about that.
But, does it really make sense?
What if the right side of the update for one of the columns to be updated (the new value assigned to the column being updated) is an expression?
As an example let's take a simple expression such as simple addition like this:
I know, we can break it down into three queries and write each query like the solution specified in the link that I provided!!!
But, that is ridiculous.
What if the expression is not a simple addition, rather a complicated non-linear expression?
What if left outer joins, right outer joins or full outer joins are involved!!!???
What if it is a mix of a few inner joins and a few left outer joins!!!???
I cannot believe that Sqlite cannot do this the right way.
I keep telling myself that maybe it is possible, and it is just me who hasn't been able to figure it out.
Is it just me?
Or, is Sqlite really lame?
Please advise.
Thanks.
I just needed to update a table based on a condition met by a join to another table.
Code:
update T1
set A = T2.A
from T1 inner join T2
on T2.TID = T1.TID
Then I google searched and realized that somebody else had a similar problem, and the solution was quite strange:
https://stackoverflow.com/questions/...join-in-sqlite
Here is the solution:
Code:
UPDATE
software
SET purchprice = (SELECT purchprice
FROM softwarecost
WHERE id = software.id)
where EXISTS (SELECT purchprice
FROM softwarecost
WHERE id = software.id)
However, this is really unbelievable!
What if you want to update 5 columns instead of one!!!???
It will be something like this:
Code:
UPDATE
software
SET purchprice = (SELECT purchprice
FROM softwarecost
WHERE id = software.id),
purchcount = (SELECT purchcount
FROM softwarecost
WHERE id = software.id),
purchdate = (SELECT purchdate
FROM softwarecost
WHERE id = software.id),
purchflags = (SELECT purchflags
FROM softwarecost
WHERE id = software.id),
purchCustomerId = (SELECT purchcustomerId
FROM softwarecost
WHERE id = software.id)
where EXISTS (SELECT purchprice
FROM softwarecost
WHERE id = software.id)
Do you think this makes sense!!!???
I know it works. No doubt about that.
But, does it really make sense?
What if the right side of the update for one of the columns to be updated (the new value assigned to the column being updated) is an expression?
As an example let's take a simple expression such as simple addition like this:
Code:
update T1
set A = T2.X + T3.Y + T4.Z
from T1 inner join T2
on T2.id = T1.id
inner join T3
on T3.id = T1.id
inner join T4
on T4.id = T1.id
But, that is ridiculous.
What if the expression is not a simple addition, rather a complicated non-linear expression?
What if left outer joins, right outer joins or full outer joins are involved!!!???
What if it is a mix of a few inner joins and a few left outer joins!!!???
I cannot believe that Sqlite cannot do this the right way.
I keep telling myself that maybe it is possible, and it is just me who hasn't been able to figure it out.
Is it just me?
Or, is Sqlite really lame?
Please advise.
Thanks.