Sunday, February 4, 2024

Important SQL Queries For Quick Use


 






// SQL query to duplicate the table structure without copying data

Query -> CREATE TABLE $newTableName AS SELECT * FROM $originalTableName WHERE 1=0;

// SQL query to Insert Data into Databse

Query-> INSERT INTO users (id, name, email) VALUES (1, 'John Doe', 'john@example.com');

// SQL query to Insert Data into Database Where id = some_id

Query-> INSERT INTO your_table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...) WHERE user_id = your_user_id;

// SQL query to Update Data into datbase->

Query-> UPDATE your_table_name SET column1 = new_value1, column2 = new_value2, ... WHERE id = your_user_id;

// SQL Query for Delete Record ->

Query-> DELETE FROM users WHERE id = 1;

// SELECT MAX Id From table using query

Query-> SELECT MAX(candidate_id) AS max_id FROM candidate_joining_data;

0 comments

Post a Comment