New answers tagged null
You can utilize the returning keyword which will return the value of the created serial column. If you wrap you Insert in a With expression, you can then access the returned id and insert into the second table. WITH getval(id) as (INSERT INTO table_a (some_col) VALUES (some_val) RETURNING id) INSERT into table_b (id) SELECT id from getval; where id ...
in MySQL you can create a trigger. I tried on my db and it works like a champ. CREATE TRIGGER update_id_on_b AFTER INSERT ON a FOR EACH ROW INSERT INTO b SET a_id = NEW.id; INSERT INTO a VALUES(148,'test 1'); SELECT * FROM b;
Let me start off by saying I am not a DBA, I am a developer by heart and I maintain and update our databases based on our needs. That being said, I had the same question for a few reasons. Null values make development more difficult and bug prone. Null values make queries, stored procedures, and views more complex and bug prone. Null values take ...
This is a global approach so i didn't rewrite a corrected query from question. I just want to share a useful point maybe help, So below script will check if the Column1 and Column2 is equal, Additionally used Convertion to VARBINARY to compare in case sensitive and you can remove it if not necessary. --c1 = Length of Column1 --c2 = Length of Column2 ...
Top 50 recent answers are included