1) what are columns name of both tables?
2) Is you table 2 holding value as 'fee 011' (will it always have fee prefix in all records) or table 2 is holding 011, 012 like that Read More
[CODE]SELECT * FROM billing order by tbl_code
SELECT * FROM fees order by tbl_fee [/CODE]
You run this 2 queries separately and post both exact results here (few top rows) Read More
If you add an area code as a foreign key to billing table then this query might help you:
[CODE]SELECT `date`,`destination`,`callsec`,`tbl_cost`,`callsec`*`tbl_cost` AS price FROM `fees` RIGHT JOIN billing ON `tbl_code`=`tbl_code_fk`[/CODE]
Note that table names are omitted from the query for simplicity. Also a field name for date is maybe not … Read More
Apart from slight size increase you will get some redundancy since area code is stored in two fields (not a problem if area codes do not change, but you never know - from this perspective the tbl_id is better candidate for a foreign key) Your destination number could be without … Read More
Following query may work but this may cause to slow down performance.
[CODE]SELECT `date`,`destination`,`callsec`,`tbl_cost`,`callsec`*`tbl_cost` AS price FROM billing left JOIN `fees` ON substring(destination,1,length(tbl_code)) =tbl_code[/CODE] Read More