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!