Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 592 Bytes

README.md

File metadata and controls

24 lines (19 loc) · 592 Bytes

#MySQL

###Query

#####Row number on select

SET number = 0;
SELECT @number:=@number+1 AS Number, name, phone FROM `users`;

#####Update with subselec from same table

UPDATE test AS a JOIN test AS b ON a.id = b.id SET a.name = 'New Name' WHERE a.id = 104;

#####Subquery in insert operation

INSERT INTO table(column1, column2, column3) VALUES('value1', (SELECT id FROM table AS id_value where id='SomeID'),'value3');

#####Get count of repeated data

SELECT COUNT(`title`) as repeat_counts, `title` from table GROUP BY `title` ORDER BY `title` DESC;