Multiple Queries in MS SQL Update query
I have an update query in which the where clause contains multiple queries, thus:
UPDATE Table 'tableA' SET FieldA = 'Y' WHERE ID IN (SELECT ID FROM tabA) OR ID IN (SELECT ID FROM tabB)
Ok, the query above is just a quick example of the query I have, but my question is that I have another field to set in 'tableA' whose value depends upon which of the two queries executes in the where clause. For example if Select ID from tabA returns, then I want to set a value, say in FieldB = 'First Query'.
So, is there a way of setting a local variable against each query which I can pass to the set clause, or is there another way?
Can't you just set it as a variable in php (or whatever you use)? and then include the variable in the query?
$query = "= 'Y' WHERE ID IN (SELECT ID from tabA) OR ID IN (SELECT ID from tabB)"; "UPDATE tableA SET FieldA = " . $query . ", SET FieldB = " . $query . "";