Help on MySQL query

Hello
I have two tables
1st, table name: kayitlar
AND I have two columns
A) lnbler_id(3, 5) - $teklifkayitlari[‘lnbler_id’]
B) lnbler_quantity(1, 2) - $teklifkayitlari[‘lnbler_quantity’]
2nd, table name: lnbler (The following table)

My question is:
I list products into the array with ID, no problem here
I want to include the Product Quantity in this series

Sample:
-----Product name -----|----- Product Quantity
ID3 – QATTRO LNB --|----- 1
ID5 – MDU5 LNB ------|------2

    $teklif_mdulnb = $mysqli->query("
              SELECT 
              lnbler.id,
              lnbler.urun_kodu,
              lnbler.lnb_markasi, 
              lnbler.lnb_tipi,
              lnbler.mdu_tipi,
              lnbler.lnb_cikisi,
              lnbler.lnb_fiyati,
              lnbler.lnb_para_birimi,
              lnbler.iskonto,
              lnbler.stok,
              lnbler.lnb_adi, 
              markalar.urun_markasi  
              FROM lnbler 
              INNER JOIN markalar ON lnbler.lnb_markasi = markalar.id
              WHERE lnbler.id IN (".$teklifkayitlari['lnbler_id'].")");

    while ($teklifmdulnb = $teklif_mdulnb->fetch_assoc()) {


  $urunler[] = ['urun'=>'lnbler',
                'urun_kodu'=>$teklifmdulnb['urun_kodu'],
                'marka'=>$teklifmdulnb['urun_markasi'], 
                'urun_adi'=>$teklifmdulnb['mdu_tipi'], 
                'quantity'=>$quantity,
                'b_fiyati'=>$teklifmdulnb['lnb_fiyati'],
                'para_birimi'=>$teklifmdulnb['lnb_para_birimi'],
                'iskonto'=>$mdulnb_isk,
                'id'=>$teklifmdulnb['id']];
  }

and where do we get the quantities from? Are you working on a shopping cart?

No, not the shopping cart,
With a wizard, I save IDs and quantities of selected products in the database
1st, table name: kayitlar
product_id(12, 25, 56)
product_quantities(2, 1, 4)
such as

2nd, table name: lnbler (Products table)
I list products of IDs specified by this

WHERE lnbler.id IN (".$teklifkayitlari['product_id'].")");

I want to show the quantities of
Help%20on%20MySQL%20query%20%20%20Beginners%20%20%20Learning%20PHP%20%20%20PHPHelp

OR,
Need to save IDs and quantities in the same column?
Sample: 12-2, 25-1, 56-4 such as ?

i don’t see the problem, maybe because i don’t understand your table layout

http://sqlfiddle.com/#!9/2206c7/2

I want to run this query,
NOTE: I use INNER JOIN as above,

create table records (id int, product_id varchar(50), product_quantity varchar(50));
insert into records (id, product_id, product_quantity) values 
(1),(2, 4, 6, 9),(3, 5, 1, 4)
;

create table product_info (id int, name varchar(50));
insert into product_info (id, name) values
(1, 'stuff'),
(2, 'crap'),
(3, 'lost'),
(4, 'bbbb'),
(5, 'cccc'),
(6, 'dddd'),
(7, 'eeee'),
(8, 'ffff'),
(9, 'gggg'),
(10, 'hhhh')
;

Real query,
Must be two lines but worked one line
product_quantity: 1, 3 // Must be 1, not 1.3

http://sqlfiddle.com/#!9/053fb4/19/0

change the product quantity value then. Doesn’t really make sense that quantity is a text type.

For “2, 4, 6, 9” what should be?
product_id varchar(50) => product_id int(50) ?

I wrote wrong and deleted it, I took it back and fixed it.
Can’t see the message?

INSERT INTOteklif_kayitlari(id,product_id,product_quantity) VALUES(1, '4, 2', 1);

I don’t understand what this is
Another quantity for ID 4
Another quantity for ID 2
VALUES(1, ‘4, 2’, 1);=====> VALUES(1, '4, 2', '1,3');

What for do you save a quantity of “1, 3” when you want to save a quantity of “1”?

I solved this problem

“product_id” provides a loop

              WHERE lnbler.id IN (".$teklifkayitlari['product_id'].")");
$product_quantity = explode(", ", $teklifkayitlari['product_quantity']);
$i = 0;
    while ($teklifmdulnb = $teklif_mdulnb->fetch_assoc()) {


  $urunler[] = ['urun'=>'lnbler',
                'urun_kodu'=>$teklifmdulnb['urun_kodu'],
                'marka'=>$teklifmdulnb['urun_markasi'], 
                'urun_adi'=>$teklifmdulnb['mdu_tipi'], 
                'quantity'=>$product_quantity[$i],
                'b_fiyati'=>$teklifmdulnb['lnb_fiyati'],
                'para_birimi'=>$teklifmdulnb['lnb_para_birimi'],
                'iskonto'=>$mdulnb_isk,
                'id'=>$teklifmdulnb['id']];
$i ++;
  }

Maybe I couldn’t fully explain
but i solved the problem
thank you everyone

Sponsor our Newsletter | Privacy Policy | Terms of Service