Last active
November 5, 2019 05:39
Revisions
-
mrabbani revised this gist
Nov 5, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ ## MySql fetch data by conditional order Suppose, You want to search product with specified key and the products with stock should appear first in the search result. SELECT * FROM `products` WHERE name LIKE 'na%' -
mrabbani revised this gist
Oct 22, 2018 . No changes.There are no files selected for viewing
-
mrabbani revised this gist
Oct 22, 2018 . 1 changed file with 6 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,4 +5,9 @@ Suppose, You want to search product with specified key and the products with sto ORDER BY CASE WHEN id IN (602, 603, 18125) THEN 1 ELSE 2 END, name ASC ## Add Virtual field //add p_type as virtual field SELECT name, 'mahbub' as p_type from products -
mrabbani created this gist
Sep 27, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ ## Prority Search Suppose, You want to search product with specified key and the products with stock should appear first in the search result. SELECT * FROM `products` WHERE name LIKE 'na%' ORDER BY CASE WHEN id IN (602, 603, 18125) THEN 1 ELSE 2 END, name ASC