Skip to content

Find records which cross-reference each other

I want to extract all the rows from a database table, where the rows cross-reference each other. My table contains 2 rows: ref1 & ref2 Table example: In this case, I want my query to return only rows 01 and 03, because they cross-reference each other. Is this possible using a single query, or will I need …

SQL Update if parameter is not null or empty

I searched some ways to check if a SQL Server parameter is not null or empty but I’m not sure what’s the best way to use this when updating several columns: I had this code at first that was updating without checking for empty or Null values: Then I added an IF clause before updating, it is workin…

How to allow only one row for a table?

I have one table in which I would like only one entry. So if someone is trying to insert another row it shouldn’t be allowed, only after someone deleted the previously existing row. How do I set a rule for a table like this? Answer A UNIQUE constraint allows multiple rows with NULL values, because two N…

Update row with select on same table

I’m trying to update row with same table query. Context: I want to : For each row; if TEXT IS NULL; update it with TEXT value of row with same ID and LANG = ‘EN’. What is the SQL request to do something like that ? Answer You don’t specify the database. The following is standard SQL: I…