asmith Posted November 30, 2007 Share Posted November 30, 2007 select field_name from table_name where id="3"; this code show the value for filed_name , how can i have backward ? i mean if i have a value, i want to search this value belongs to what column ? what is the column name where id=3 and its value is "aaa" . Link to comment https://forums.phpfreaks.com/topic/79531-select-vice-versa/ Share on other sites More sharing options...
fenway Posted November 30, 2007 Share Posted November 30, 2007 Why would you not know where a value was? Link to comment https://forums.phpfreaks.com/topic/79531-select-vice-versa/#findComment-402919 Share on other sites More sharing options...
asmith Posted November 30, 2007 Author Share Posted November 30, 2007 if a table has 20 fields, with 20 rows, how do you find out a value is stored in table or not ? field 1 filed 2 filed 3 filed 4 filed 5 .... filed 20 row1 row2 row3 abc row4 row5 row6 . . . row20 how do you search whether abc is recorded in this table or not ? and find its exact position ? Link to comment https://forums.phpfreaks.com/topic/79531-select-vice-versa/#findComment-402938 Share on other sites More sharing options...
fenway Posted November 30, 2007 Share Posted November 30, 2007 You'd have to check each one and return a boolean of sorts: IF( field1 = 'abc', 'field1', IF( field2 = 'abc', 'field2' ) )...etc.. Assuming it can never be in two fields at one. I still don't understand why you have such a table. Link to comment https://forums.phpfreaks.com/topic/79531-select-vice-versa/#findComment-402949 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.