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

how to get last element sql

	Select Distinct names.xyz
       From nameList names
       LEFT JOIN nameList idNum
       ON idNum.xyz > names.xyz AND idNum.xyz IS NOT NULL
       WHERE idNum.xyz IS NULL
Comment

PREVIOUS NEXT
Code Example
Sql :: postgresql to_char time 
Sql :: sql view where tables have same column name combine results 
Sql :: mysql regex replace 
Sql :: mysql CAST(amount as float) 
Sql :: mysql url 
Sql :: mysql trim 
Sql :: how to check if a row is null in sql 
Sql :: execute stored procedure 
Sql :: amazon linux postgresql client 
Sql :: check if string is a number sql 
Sql :: csv to sqlite python 
Sql :: sql in array query 
Sql :: date_part mysql 
Sql :: how to find sql server agent jobs related to a database 
Sql :: how to assign date field for table in mysql 
Sql :: how to delete user in mysql 
Sql :: mysql on update current_timestamp 
Sql :: How to drop a foreign key constraint in mysql ? 
Sql :: describe table postgres 
Sql :: how to create a table in mysql 
Sql :: string to sql timestamp 
Sql :: mysql datetime to date 
Sql :: remove unique key from a table 
Sql :: alter table add multiple columns postgresql 
Sql :: mysql copy table to another table 
Sql :: update and replace mysql 
Sql :: sql #region 
Sql :: check if a column is a primary key in sql server 
Sql :: mysql add column to table 
Sql :: mariadb json select 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =