Coder Baba
2.41K subscribers
1.01K photos
23 videos
722 files
723 links
Everything about programming for beginners.
1 and only official telegram channel of CODERBABA India.

Content:
.NET Developer,
Programming (ASP. NET, VB. NET, C#, SQL Server),
& Projects
follow me https://linktr.ee/coderbaba
*Programming
*Coding
*Note
Download Telegram
sharing some Interview questions #sql #intermediate

1. How to select random rows from a table?
-> Using the RAND() function in combination with ORDER BY and LIMIT. In Mysql we use RAND() which returns random records from table.
SELECT * FROM table_name
ORDER BY RAND()
LIMIT 5;

2. How to find the last id in a table?
-> By using MAX(), We use following syntax
SELECT id
FROM table_name
ORDER BY id DESC
LIMIT 1;

3. How to find the values in a text column of a table that start with a certain letter?
-> Using the LIKE operator in combination with the % and _ wildcards. For example, we need to find all surnames in a table that start with "A". The query is:
SELECT * FROM table_name
WHERE surname LIKE 'A_';