I have two tables (items and sub_items). Both tables have an asset_number column. I need a query that will let me add a new item only if the given asset_number is not present in either of the two tables.
Can you be more specific on the fields?
Does your sub_items table have itemsId?
If yes, I think you can join those two tables and search for the new item?
Something like this:
SELECT I.item_id AS item_items_id, SI.item_id AS subitem_items_id FROM items I
INNER JOIN sub_items SI ON I.item_id = SI.item_id AND I.asset_number = SI.asset_number
WHERE I.item_id = -- if your new item has an item_id you can search it
If the new item doesn't have an ID, then maybe you can search by using a item name if there is a column?
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments