20 Ocak 2022 Perşembe

INSERT INTO + SELECT

Örnek
Şöyle yaparız
INSERT INTO suppliers (supplierName)
  SELECT customerName FROM customers WHERE country = 'USA' AND state = 'CA';
Örnek
Şöyle yaparız
INSERT INTO stats(totalProduct, totalCustomer, totalOrder)
VALUES(
  (SELECT COUNT(*) FROM products),
  (SELECT COUNT(*) FROM customers),
  (SELECT COUNT(*) FROM orders)
);
Örnek 
 Ben şöyle yapmıştım. Böylece phone alanına sabit bir değer verebilmiştim
INSERT INTO suppliers supplierName, phone
  SELECT customerName, 12345 FROM customers WHERE country = 'USA' AND state = 'CA';


Hiç yorum yok:

Yorum Gönder

Soft Delete

Giriş Açıklaması  şöyle When using the soft delete mechanism on the database, you might run into a situation where a record with a unique co...