Search
 
SCRIPT & CODE EXAMPLE
 

SQL

get only first row mysql

/**
To return only one row use LIMIT 1:
**/

SELECT *
FROM tbl_foo
WHERE name = 'sarmen'
LIMIT 1

/**
It doesn't make sense to say 'first row' or 'last row' unless you have an ORDER BY clause.
Assuming you add an ORDER BY clause then you can use LIMIT in the following ways:
To get the first row use LIMIT 1.
To get the 2nd row you can use limit with an offset: LIMIT 1, 1.
To get the last row invert the order (change ASC to DESC or vice versa) then use LIMIT 1.
**/
Comment

PREVIOUS NEXT
Code Example
Sql :: sql like 
Sql :: creer une base de donnée psql 
Sql :: oracle last day of month 
Sql :: minus vs intersect in sql 
Sql :: oracle sysdate 
Sql :: sql update from different table 
Sql :: mysqli_connect using prepare statement 
Sql :: pgAdmin - Please correct the Binary Path 
Sql :: sql problems 
Sql :: select amount weeks between two dates mysql 
Sql :: how to drop a database in sql server when it is in use 
Sql :: sqlserver docker 
Sql :: create database hive 
Sql :: blob datatype in mysql 
Sql :: mysql get all tables row count 
Sql :: ubuntu reset mysql root password 
Sql :: current year sql 
Sql :: how to add CHECK constraint to a column in postgres 
Sql :: mysql change collation one column 
Sql :: show tables in cassandra cql 
Sql :: 2nd highest salary in mysql 
Sql :: mysql set id auto increment 
Sql :: execute stored procedure 
Sql :: mamp mysql path mac 
Sql :: mysql set password for user 
Sql :: how to drop all tables in postgresql 
Sql :: how to delete user in mysql 
Sql :: mysql timediff 
Sql :: row number mssql 
Sql :: select last row mysql 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =