jaiffed Posted February 17, 2010 Share Posted February 17, 2010 hello, I am currently working in mysql and php for my project, my problem is to select fields from diffrent table .......... I have a database name memmanage it have two tables mem_master and book_master now what is the query to select mem_id from mem_master and book_name from book_master where book_master avail=1 please help me ......... Link to comment https://forums.phpfreaks.com/topic/192420-mysql-select-query-problem/ Share on other sites More sharing options...
jl5501 Posted February 17, 2010 Share Posted February 17, 2010 You will need to supply a little more detail on the structure of those 2 tables, so someone can advise you the best way to join them to get the information you need. Link to comment https://forums.phpfreaks.com/topic/192420-mysql-select-query-problem/#findComment-1013873 Share on other sites More sharing options...
jaiffed Posted February 17, 2010 Author Share Posted February 17, 2010 mem_id is the field of table mem_master, book_name is the field of book_master, and avai is the field of book_master which has only 0/1 now i think you'll understand this please help Link to comment https://forums.phpfreaks.com/topic/192420-mysql-select-query-problem/#findComment-1013877 Share on other sites More sharing options...
jl5501 Posted February 17, 2010 Share Posted February 17, 2010 can you supply the complete structure of both tables, in particular any fields in one table which relate to fields in the other Link to comment https://forums.phpfreaks.com/topic/192420-mysql-select-query-problem/#findComment-1013881 Share on other sites More sharing options...
jaiffed Posted February 17, 2010 Author Share Posted February 17, 2010 this is my mysql query create database libmanage; use memmanage; create table mem_master (mem_id int not null primary key, mem_name varchar(100) not null, add1 varchar(250), add2 varchar(250), tel varchar(50), mobile varchar(50), email varchar(50), date date, balance int default 0); create table book_master (book_id int not null primary key, book_name varchar(250) not null, supp_id int, avail int default 0, from this i want to query which select mem_id from mem_master and book_name from book_master where avail from book_master value is 1 Link to comment https://forums.phpfreaks.com/topic/192420-mysql-select-query-problem/#findComment-1013888 Share on other sites More sharing options...
jl5501 Posted February 17, 2010 Share Posted February 17, 2010 Ok so from what you have supplied, there is no connection between the 2 tables, meaning no relationship between a member and a book. To combine data from different tables, you need some sort of relationship between them, like a book_id in the mem table or a mem_id in the book table. How you do that would depend very much on what you are trying to achieve here. Link to comment https://forums.phpfreaks.com/topic/192420-mysql-select-query-problem/#findComment-1013896 Share on other sites More sharing options...
jaiffed Posted February 17, 2010 Author Share Posted February 17, 2010 i solved this thanks you for trying to help me..... Link to comment https://forums.phpfreaks.com/topic/192420-mysql-select-query-problem/#findComment-1013908 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.