DiH DiH - 3 months ago 8
SQL Question

Select from two tables without CommonElement

I want making select from two tables without any common element
I'm trying this code, but I get incorrect syntax near ','.

select top 1 inventory.name, customer.name
from inventory
where inventor.name='test' , customer where customer.name='test2'

Answer

It leads to cartesian product of two tables. (Cross Join). Try like this,

SELECT TOP 1 i.NAME
    ,c.NAME
FROM inventory i
cross join customer c
WHERE i.NAME = 'test'
    AND c.NAME = 'test2'