SQL Database Query Examples

Simple SELECT Query

Select all columns from the 'users' table

                
                    SELECT * FROM users;
                
            

Filtering with WHERE Clause

Select users older than 30

                
                    SELECT * FROM users WHERE age > 30;
                
            

Joining Tables

Select user names and email addresses from the 'users' and 'emails' tables

                
                    SELECT u.name, e.email
                    FROM users u
                    JOIN emails e ON u.id = e.user_id;
                
            

Inserting Data

Insert a new user into the 'users' table

                
                    INSERT INTO users (name, age, email)
                    VALUES ('John Doe', 35, 'john.doe@example.com');