Table A
Value
3
How to do a sql query to assign 'medium' based on the value in the Table A? The category will be referenced from Table B.
I can think of case when...then (hard-code) in the sql query. Is there any alternative way to write the query?
Table B
Category Min Max
Low 0 2.99
Medium 3 4.99
High 5 5.99
SQL query other than "case when...then"
Re: SQL query other than "case when...then"
Hi,
try something like this (pseudo code)
PS: You need only min or max in your table, as the other one automatically is pure logic - your SQL will probably get more complex
PSPS: You should use different fieldnames (not min and max).
Olaf
try something like this (pseudo code)
Code: Select all
$sql = "select category from tableB where min <= " . $value . " AND max >" . $value . ";"
$result= sqlValue($sql)
PSPS: You should use different fieldnames (not min and max).
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: SQL query other than "case when...then"
Thanks. Your suggestion work in php.
Just wonder how to implement this to the calculated field. As I now there is pesudo code for id, primary key and table..
but, how to custom a pseudo-code?
Just wonder how to implement this to the calculated field. As I now there is pesudo code for id, primary key and table..
but, how to custom a pseudo-code?