database:mysql
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
database:mysql [2023/11/02 10:56] – [Mysql basic commands] skipidar | database:mysql [2023/11/02 11:04] (current) – skipidar | ||
---|---|---|---|
Line 517: | Line 517: | ||
== IFNULL(), ISNULL(), COALESCE(), and NVL() Functions == | == IFNULL(), ISNULL(), COALESCE(), and NVL() Functions == | ||
- | | '' | + | | '' |
+ | | '' | ||
| '' | | '' | ||
Line 525: | Line 526: | ||
SELECT ProductName, | SELECT ProductName, | ||
FROM Products; | FROM Products; | ||
+ | |||
+ | |||
+ | --- using boolean ISNULL | ||
+ | SELECT OrderID, | ||
+ | CASE | ||
+ | WHEN ISNULL(AmountDue) THEN "Paid in full" | ||
+ | WHEN DATE(DueDate) < date(NOW()) THEN "Order is past due" | ||
+ | ELSE CONCAT(" | ||
+ | END | ||
+ | FROM OrderDetails; | ||
+ | |||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | == Stored Procedure Example == | ||
+ | |||
+ | |||
+ | <sxh sql> | ||
+ | |||
+ | --- procedure | ||
+ | CREATE PROCEDURE SelectAllCustomers | ||
+ | AS | ||
+ | SELECT * FROM Customers | ||
+ | GO; | ||
+ | |||
+ | --- execute | ||
+ | EXEC SelectAllCustomers; | ||
+ | |||
+ | |||
+ | |||
+ | --- procedure with args | ||
+ | CREATE PROCEDURE SelectAllCustomers @City nvarchar(30) | ||
+ | AS | ||
+ | SELECT * FROM Customers WHERE City = @City | ||
+ | GO; | ||
+ | |||
+ | --- exec | ||
+ | EXEC SelectAllCustomers @City = ' | ||
+ | |||
+ | </ | ||
+ | |||
database/mysql.1698922582.txt.gz · Last modified: by skipidar