[Solved] How to SELECT and INSERT until ordered quantity is completed using nested query in MySQL

I hope and imagine that there must be a more performant solution, but anyway, consider the following: Schema (MySQL v8.0) DROP TABLE IF EXISTS product_batches; CREATE TABLE product_batches (batch_number SERIAL PRIMARY KEY ,product_id INT NOT NULL ,quantity_available INT NOT NULL ); INSERT INTO product_batches VALUES ( 1,1,15), ( 3,1, 5), ( 7,1,20), (10,1,30), (11,1,50); Query … Read more

[Solved] MySql database structure for : Search based on single column and different value [closed]

try this: create table City ( Id int, Name varchar(50) ); insert into City (Id, Name) VALUES (1, ‘Toronto’), (2, ‘Chicago’) create table Libraries( Id int, Name varchar(50), CityId int ); insert into Libraries (Id, Name, CityId) VALUES (1, ‘Toronto Library 1’, 1), (2, ‘Toronto Library 2’, 1), (3, ‘Chicago Library 1’, 2), (4, ‘Chicago … Read more

[Solved] How to use multiple inner joins

I see that your custumers are identified by the telephone number, i don’t think that is a good idea, since telephone number can change quite often in your custumer table, anyway this should be the query. SELECT SA.* FROM STATAMENT_OF_ACCOUNT_TBL SA JOIN OFFICIAL_RECEIP_TBL R ON SA.STATEMENT_ACC_NO=R.STATEMENT_ACC_NO JOIN CUSTUMER_TBL C ON C.CUS_TEL_NO=R.CUS_TEL_NO WHERE C.CUS_TEL_NO=’422-9418′ Ah, and … Read more

[Solved] save array to mysql using php [closed]

If you’re planning on saving all of the array as one string in the database you can just use mysqli_query, and mysqli_real_escape_string: Saving all of the array as one string: $arr = [“002012295915”, “00971595502”, “8885555512”, “5555648583”, “4085555270”, “0562825196”, “01147220964”]; $con = mysqli_connect(“localhost”,”root”,”pass”,”db”); mysqli_query($con,”insert into TABLE values(‘”.mysqli_real_escape_string($con,$arr).”‘)”); And if you want to print it later just … Read more

[Solved] column based mysql results in php [closed]

assuming you have a mysql table setup like this https://www.dropbox.com/s/cth0mkfwt382z0g/Screenshot%202014-08-20%2016.27.48.png and you have your php files setup to db properly //query database for data $result = mysql_query(“SELECT question, answer, ip FROM test_answers”); //Create some arrays $answer_array = array(); $ip_array = array(); $question_array = array(); //loop through the mysql data and populate the arrays while ($row … Read more

[Solved] php ‘ISSET’ function not working. OR the code skips my if statements

In addition to the supplied answer(s), I would like to suggest doin the following: // Before anything else, start your session if (!isset($_SESSION)) { session_start(); } // Next, check if your form is actually submitted if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’) { if (isset($_POST[‘…’])) { } elseif (isset($_POST[‘…’])) { } } ?> <!– Keep PHP and html … Read more

[Solved] How to use group by in this cquery?

SELECT eav.value AS ‘unspsc’,COUNT( e.sku) FROM catalog_product_entity e JOIN catalog_product_entity_varchar eav ON e.entity_id = eav.entity_id JOIN eav_attribute ea ON eav.attribute_id = ea.attribute_id WHERE ea.attribute_code=”unspsccode” GROUP BY eav.value solved How to use group by in this cquery?

[Solved] Create a simple php array using mysql rows… [closed]

Here’s a technic : <?php // Query the database SELECT product_id FROM product // Loop $Products = array(); while(){ $Products[] = $Row->product_id; } print_r($Products); ?> Try something by yourself. Use PDO extension to create your query and then use the method fetch to get your data in the loop. 0 solved Create a simple php … Read more