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 1 year ago.
Improve this question
Below is my SQL table
| ID | Value |
| 1 | A1 A2 A3 |
I would like to delete the A3 in the column: Value. Is there any method to do this?
There's no way to edit/remove part of string, you just need to update whole cell. It's up tou you, how you'll prepare update data in your code.
SQL:
update tablename set Value = 'A1 A2' where ID=1
Related
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 have nested/tree database.
I need php function to call sub-parents to top parent when i call an id child. Below is example of my mysql structure database.
|id |ket|
--------------
|01 |A |
|0101 |B |
|010101 |C |
|010102 |D |
|01010101|E |
So, as an example if i call 01010101 it will return A-B-C-E
Any ideas how to make it happen.
Many thanks
By treating the id as the beginning of a pattern:
SELECT ket
FROM tbl
WHERE "01010101" LIKE CONCAT(id, '%')
BTW - horribly inefficient and no index use possible.
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 years ago.
Improve this question
This is my sql outcome:
What I am trying to achieve is to show the garden and under that it shows the hose pipe ,lawn moar etc.
How to write the query?
If I understand you correct you would normaly do that somehow like that.
cat_id | parent_id | cat_name | cat order
1 0 Garden 1
2 1 Hose Pipe 1
3 1 Lawn Moar 2
in this case Garden for example would have the cat_id 1 and parent_id 0 and all subcategories have their own incremented id and the parent_id of garden, which would be 1 in this case!
then you can query for your categories and foreach of them query for the subcategories where the parent_id is the cat_id of the maincategory!
here you have a nice tutorial on how to display it recursive:
https://www.codexworld.com/dynamic-category-subcategory-tree-php-mysql/
that way you also only need to save the imagepath only once in your maincat!
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 7 years ago.
Improve this question
In my MySQL database, I'm trying way of creating a table to track daily views on 100 items. Each day would insert a new row for each item. So the table columns would look like this:
| ItemID | ItemName | Hits |
Is there a way to store daily hits for items?
What you could do is have a table with a structure like:
| item_hits |
|---------------|
| itemID | date |
Then your SQL query could look like
SELECT count(*) FROM item_hits WHERE date = '2015/04/15' and itemID = 7;
You wouldn't need to save the itemName in the table, because you should be able to get the itemName by joining it to your items table.
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 8 years ago.
Improve this question
i have here
table_A
| Customer ID | moneyspent |
001 50
002 30
003 20
003 20
002 30
i have seen a query that gets the sum of all moneyspent from table A
SELECT SUM(moneyspent) FROM table_A
but i want the results to be inserted in table B's column"totalspent" like this
table_B
| Customer ID | totalspent |
001 50
002 60
003 40
help pls.
thanks
Try this, it works I've checked:
INSERT INTO table_B (Customer_ID, totalspent)
(SELECT Customer_ID, sum(moneyspent) FROM table_A group by Customer_ID)
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 9 years ago.
Improve this question
I intend that after selecting an option from a list, a new list appears according to the option selected.
But the second select list, sends a query to the database, depending on the choice list in the first select!
example:
table bd
| A | 1 |
| A | 2 |
| B | 3 |
| B | 4 |
first select
A or B
second select
if select A
1
2
if select B
3
4
A simple search for a filtered dropdown list brought me to the following code on GitHub which does a decent job explaining how to program one of these lists on your own. You can find it here.
Hope this helps.