DEV Community

pooyaalamdari
pooyaalamdari

Posted on

Read data from selected columns with a specific ID

Image description

SELECT title, author, price 
FROM books
WHERE bookid = 4
Enter fullscreen mode Exit fullscreen mode

Image description

To select multiple bookids, you can use the IN clause in your SQL query. Here's how you can modify your code to select multiple bookids:

SELECT title, author, price 
FROM books
WHERE bookid IN (4, 5, 7) -- Replace 4, 5, 7 with the IDs you want to select
Enter fullscreen mode Exit fullscreen mode

This will allow you to retrieve data for books with bookid 4, 5, and 7. You can include as many bookids as you need within the parentheses, separated by commas.

Image description

Top comments (0)