Writing SQL
Using SELECT
to Retrieve Values
SELECT * FROM users
-- For strings, enclose with quotation marks
WHERE ({{ emailInput.value === "" }} OR email LIKE '%{{ emailInput }}%')
-- For numbers or booleans, quotation marks are not needed
AND ({{ !checkbox.value }} OR is_admin = {{ checkbox.value }})
By using ({{ emailInput.value === "" }} OR email LIKE '%{{ emailInput }}%')
, you can retrieve all records if the value is empty.
Using INSERT
to Add Data
INSERT INTO users (name, email, is_admin)
VALUES ('{{ nameInput.value }}', '{{ emailInput.value }}', {{ isAdminCheckbox.value }})
Using UPDATE
to Modify Data
UPDATE users SET email = '{{ emailInput.value }}'
WHERE id = {{ table1.selectedRow.data.id }}
Using DELETE
to Remove Data
DELETE FROM users
WHERE id = {{ table1.selectedRow.data.id }}