As the title indicates, I would like to query a Table "Table1" with the results obtained from another Table "Table2"
CONSULTATION 1
To get the data from the Table1
SELECT id FROM box_12.esale_rc WHERE kind=30;
which gives me as a result the fields "id" (INT) of 107 lines:
| id | |-----| | 86 | | 436 | | 438 | | ... | | ... |
CONSULTATION 2
Before I should mention that the field involved in this query "detail" (VARCHAR) is a text string ("eSale invoice at De Test # 4 ") that inside contains the " id " that I get from Table1 so I must convert and extract the necessary data < strong> "OrderId" .
To get the results of the Table2
SELECT id, st, detail,
CONVERT(SUBSTR(detail,(LOCATE('#',detail) +1)), UNSIGNED INTEGER)AS OrdenId
FROM box_12.warehouse_rc
WHERE LOCATE('#',detail)>0
ORDER BY OrdenId DESC;
Which gives me as a result 4271 lines:
| id | st | detail | OrdenId | |:----:|:---:|:---------------------------------:|:--------:| | 4273 | 16 | eSale invoice # 5117 (Traje Baño) | 5117 | | 4272 | 16 | Sale invoice # 5116 (Traje Baño) | 5116 | | 4270 | 16 | eSale invoice # 5115 (Outlet) | 5115 | | 4271 | 16 | eSale invoice # 5114 (Traje Baño) | 5114 | | ... | ... | ... | ... | | ... | ... | ... | ... |
THE EXPECTED
I need to be able to make a query where the results of the Query1 the (107) lines are the conditions for the Query2 to give me only the ids of the 107 expected results .
all this in order to do a UPDATE after the st
fieldGreetings, I hope you have explained me well.