0

hi here i have two tables named as test and test2.

test is as follows

enter image description here

test2 is as follows

enter image description here

i am using below sql code to get the below output.

UPDATE `test`
SET `availability` = 'ok'
WHERE
    `id` = '(SELECT
test.id
FROM
test2
INNER JOIN test ON test.id = test2.PId)';

I requires below output. but it outcomes no any output. kindly help. any mistakes done by my end or if there is any best mothod to get below output, kindly mention

enter image description here

0

3 Answers 3

1

I think you're looking for something along the lines of

UPDATE test 
INNER JOIN test2 on test.id = test2.PId
SET test.availability = 'OK'
Sign up to request clarification or add additional context in comments.

Comments

0

Sounds like you don't need an update, just a query with a join:

SELECT test.id, test.name, CASE WHEN teste2.pid IS NOT NULL THEN 'OK' END
FROM   test
JOIN   test2 ON test.id = test2.pid

1 Comment

hi i jut need to update the value to the 'availability' column is that possible, i hope i should use an update query to enter ok value for the availability column.
0

I am not sure if this will work.but hey we all try here right..

UPDATE `test`
SET `availability` = 'ok'
WHERE
`id` in '(SELECT
PId from test2)';

I don't get , why do you need inner join.You only need those id's that are present in test2 table,then just take it. although i have used 'in' keyword,try with '=' also but i doubt it will work because inner query is returning a list of id's.thanks.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.