MySql query with PHP [closed]

0

I have 2 tables: Students and Prestamos_Libros. The table Prestamos_Libros has a state field with three possibilities, 1, 2 and 3.

the table Students has 15,000 records, of which 259 records belong to group 10. I can list the students of group 10 who have borrowed books (state 1 and 3), they are 127, but I need to know the students of group 10 that they have not borrowed books (ie state 2).

    
asked by Alexander Celin Barraza 23.03.2016 в 03:07
source

2 answers

1

Your question does not leave your doubt very clear, but as soon as I understood if in group 10 there are 259 records in total.

You say that your table We give books has 3 states (1,2,3) and if you can list the records that have borrowed books, states (1 and 3) to what gives you 127.

If you say that state 2 corresponds to books not loaned, simply to the total of records "259" you subtract "127" that corresponds to the books loaned, states 1 and 3, which will give you the records of state 2.

This query is done in the same way you consulted the borrowed books, even simpler.

but in any case for a clear answer you need to present your query and structure of tables as you have already commented.

    
answered by 21.04.2016 в 04:25
0

You should put the structure of the tables, to know exactly how the books are related to the students, since depending on the relationship, the query is done one way or another

    
answered by 20.06.2016 в 16:41