Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I want to get values from the other rows by selecting a specifc text from the quotes from items row
Image:
I tried all the ways I've know but nothing of them working.. example
$this->f3->get('DB')->exec('select tops.id, tops.name, tops.img from tops where tops.items = 1 ');
So what I want I want to select that "1" or "2" from items row ( check the image )
If the row you show in the image is an example of what you are attempting to select, then the SQL string you should be using would be:
'select tops.id, tops.name, tops.img from tops where (tops.items like \'%"1":%\' or tops.items like \'%"2":%\');'
This will select rows where the tops.items column contains either "1": or "2":. If you are trying to match something else, then please try to be a bit clearer in your question.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 days ago.
Improve this question
I was trying to make a looping table in php with the rules:
Make a table (col:36, row:57) then give looping value (col 1-36) and (row 1-57) to the first column and row, so the middle is blank column.
Make a table with size (col:36, row:57) then the table have a colspan at [2,2], [15,2], [2,27], [36,27] 4 columns each.
Make a table with size (col:36, row:57) with colspan and rowspan at line [2,2], [15,2], [2,27], [22,27] 4 columns and 2 rows each.
Help me please
I was try, but each column have a value, so, how to give value just for the first column and row only?
I have no idea
I have no idea
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to add data to mysql table without removing old data of that column
stock = 50
now i want to add 5 more
so i want to get result in table as: stock = 50+5 or stock=60
how i can do this in SQL
This is a simple SQL statement
UPDATE myTable Set stock = stock + 5 WHERE ...
You use update:
update t
set stock = stock + 5
where <whatever condition fro the row you want to set>;
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am working for small project, the main idea of the project to display
some tours:
DB - Database consist of 2 table like below
The first table consist of 4 raw:
id , tour_id , tour_name, image
and the second table for each tour details like destination and places
and raw is:
id , tour_id , from , to
The main page is done, I can display information of tour with images and url link to details page like www.domain.com/tours/get_tour?=1
where 1 is the tour_id.
My question is how can I show the information from the second table with respect tour_id?
I am working in PHP and HTML and MYSQL.
You need JOIN function of mysql. The use this type of SQL script with PHP:
$sql="SELECT first.tour_id, first.tour_image, second.tour_id
FROM first
JOIN second ON first.tour_id=second.tour_id;";
$results=$conn-->$sql; //with $conn your connection variable
$get_tour = $result->fetch_assoc();
In this way you can get first.tour_name and second.from/to depending on tour_id
Then run a while to export your datas in PHP.
$get_tour is now populated. To call elements, use
$get_tour['first.tour_id'];
$get_tour['second.from'];
...
Let me know if it works!
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have this code to output the value in table i used group by to
group the same item code but serial does not show it only show
onevalue the 123321. The output should be 123321,4354
$invoicequery=mysqli_query($link,"Select SUM(INVOICE_ITEM_QTY_MX),INVOICE_ID_MX,INVOICE_ITEM_UPRICE_MX,INVOICE_ITEM_AMOUNT_MX,INVOICE_ITEM_SERIAL_MX,INVOICE_ITEM_DESC_MX,INVOICE_ITEM_CODE_MX from invoice WHERE BRANCH_CODE_MX='".$display_branchcode."'
and INVOICE_NO_MX='".$invoicecode."' GROUP BY INVOICE_ITEM_CODE_MX");
while($row=mysqli_fetch_array($invoicequery))
{
$invoiceid=$row["INVOICE_ID_MX"];
$itemcode=$row["INVOICE_ITEM_CODE_MX"];
$itemquantity=$row['SUM(INVOICE_ITEM_QTY_MX)'];
$unitprice=$row["INVOICE_ITEM_UPRICE_MX"];
$amount=$row["INVOICE_ITEM_AMOUNT_MX"];
$serialimei=$row["INVOICE_ITEM_SERIAL_MX"];
$itemdescription=$row["INVOICE_ITEM_DESC_MX"];
}
Ouput
In Database
It sounds like you are looking for MYSQL's GROUP_CONCAT() function method. Simply wrap the column name you wish to have returned as a comma separated list with that function like you have used MAX().
Example:
SELECT student_name,
GROUP_CONCAT(test_score)
FROM student
GROUP BY student_name;
This will return, for example,
student_name | test_score
Becky C. | 80, 77, 95
Note that this value will be truncated according to your db's group_concat_max_len setting.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I made a new question cause I don't understand the other answers.
I want to get clear here.
I have a table named "experiences".
It has THREE FIELDS: id, experience_name, years.
I want to combine the TWO COLUMNS : experience_name and year and name it like.. experience
Then i want to make a new table and name it resume_experiences and put the COLUMNS id and experience
can you guys please help me..
How am i gonna do it?
OUTPUT SHOULD BE:
table name: resume_experiences
fields: ID | EXPERIENCE
Try this:
INSERT INTO resume_experiences
(id, experience)
SELECT id, CONCAT(experience_name, ' ', CONVERT(years,UNSIGNED))
FROM experiences
CREATE TABLE IF NOT EXISTS `resume_experiences `
SELECT `id`, CONCAT(`experience_name`, ' ', `years`) AS `experience`
FROM `experiences`;