Using If else conditional statement on where condition mysql
Using if / else on the mysql would be much easier to express with simple query. Her we go:
Assume you have the following table:
+--------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------+--------------+------+-----+---------+----------------+ | file_id | int(11) | NO | PRI | NULL | auto_increment | | file_path | text | NO | | NULL | | | file_name | varchar(120) | NO | MUL | NULL | | | file_size | bigint(20) | YES | | NULL | | | file_content | text | NO | MUL | NULL | | +--------------+--------------+------+-----+---------+----------------+
Then you want to collect records either by file_id or by file_size based on the file_size, if the file size above some value, check the name of the file to contain xls, otherwise, consider only files that have file id more than y
select * from file where if (file_size > x, file_name like '%.xls', file_id > y)
YUP!
See how you would solve these known algorithm problems
Find K Complementary numbers from array Java implementationCheck if there are three numbers a, b, c giving a total T from array A
Kadane’s algorithm in C – Dynamic Programming
Implementing tokenizer and adding tokens to the linked list
String Ordered Permutation Algorithm Problem
Check if two strings are anagrams or not
Find the pairs that makes K Complementary in the given array java solution
Changing decimal number to its binary equivalent
Get maximum occurring character
Flatten nested javascript array