get data from 2 tables

0

I have an invoice table with the fields number, date and a table details with the fields numerofactura have their foreign key and the whole thing. I WANT TO OBTAIN ALL THE DETAILS OF THE INVOICES IN A RANGE OF DATES AND I AM SENDING YOU THIS QUERY:

SELECT factura.Numero FROM factura  INNER JOIN detalles 
ON factura.Numero=detalles.NumeroFactura 
AND factura.Fecha BETWEEN '2018-08-17' AND '2018-08-18' 

BUT IT RETURNS ME NULL. DOES SOMEBODY KNOW HOW TO SOUL?

    
asked by arsoft cr 24.09.2018 в 20:52
source

2 answers

1

Try it this way:

SELECT factura.Numero FROM factura  INNER JOIN detalles 
  ON factura.Numero=detalles.NumeroFactura 
WHERE factura.Fecha BETWEEN '2018-08-17' AND '2018-08-18' 
    
answered by 24.09.2018 в 20:54
0

I suppose that your date type field saves the data in this way: 2012-01-23 09:24:41

Try this way ..

SELECT f.Numero FROM factura  AS f
INNER JOIN detalles AS d
  ON f.Numero= d.NumeroFactura 
WHERE f.Fecha BETWEEN  CAST('2018-08-17' AS DATE)  AND  CAST('2018-08-18' AS DATE)

In case of failure, try changing .. your text string (the date), with

DATE(column_name)

I hope I have helped you ..

    
answered by 24.09.2018 в 22:21