Skip to content
Advertisement

Query using from / to tables

I have one from / to table which has some data like this:

FROM                 | TO
---------------------+----------------
Apple iPhone SE 64GB | IPHONE SE 64GB

And I have two other tables which are populated with data from the FROM and from the TO columns respectively:

Table 1:

Device               | price 
---------------------+--------
Apple iPhone SE 64GB | xxxx

Table 2:

Device         | Price 
---------------+--------
IPHONE SE 64GB | XXXX

Sometimes, using a web scraper, the tables 1 and two get populated by values which won’t exist in the From To table. For example:

Table 1:

Device         | price
---------------+--------
Samsung Flip Z | xxxx

Table 2:

Device                    | Price
--------------------------+--------
Smartphone Samsung Flip Z | XXXX

So, I’d have to insert one record inside the From To table like this:

FROM           | TO
---------------+----------------------------
Samsung Flip Z | Smartphone Samsung Flip Z

So, given these three tables, is it possible to have a query to find out which values are and which values are not in the From To Table? Because we have to fill it periodically.

Advertisement

Answer

you could use left join where don’t match

  select t1.device 
  from table1 t1
  left join  table_from_to  tft on t1.device = tft.[from]
  where table tft.[from] is null 

anyway FROM is reserved word so you should use square brackets better use another word

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement