Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql select last id

#Where the the column name is "ID" and table name is "tablename" and ID naming is increasing numerical value.
SELECT * 
FROM tablename
WHERE ID = (
    SELECT MAX(ID) 
  	FROM Table)
Comment

sql get last ID

SELECT MAX(id) FROM <tablename>
Comment

sql select last id

SELECT
  (SELECT * FROM tableName ORDER BY col1 LIMIT 1)        AS first,
  (SELECT * FROM tableName ORDER BY col1 DESC LIMIT 1)   AS last
;
Comment

PREVIOUS NEXT
Code Example
Sql :: select into temp table 
Sql :: condition in count sql 
Sql :: string to sql timestamp 
Sql :: mysql remove html tag 
Sql :: create database sql 
Sql :: sql update where id 
Sql :: Postgresql get diff between two dates in Months 
Sql :: mysql update join 
Sql :: mysql search table in all databases 
Sql :: mysql query dates between two dates 
Sql :: postgresql check privileges on schema 
Sql :: change mysql version to 5.7 in ubuntu 
Sql :: how to query without duplicate rows in sql 
Sql :: temp table vs variable table in sql server 
Sql :: mysql update with join 
Sql :: select list is not in group by clause and contains nonaggregated column codeigniter 
Sql :: if null mysql 
Sql :: postgres list users 
Sql :: sql declare variable 
Sql :: sql date format dd-mm-yyyy 
Sql :: how to check if a column is null in sql 
Sql :: mysql get all tables from a specific database 
Sql :: mysqldump with where clause 
Sql :: else if mysql 
Sql :: how to count number of rows in sql 
Sql :: postgres user permissions 
Sql :: SQL query to verify the size of the table 
Sql :: mysql load sql from file 
Sql :: mysql limit 
Sql :: oracle dba_dependencies 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =