How to get the numbers of a column in phpmyadmin? [closed] - php

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 5 years ago.
Improve this question
I have the database as below picture shown:
I want to get the numbers under "ID" colm with "0" value in "is_parent".
How to do that with a sql query?
I want the numbers going to be link this:
1792,2304,1793,1794,2308.. etc..
Tried my best, with failed attempt, hopefully someone can help me with the correct query.
Thank you,
regards.

Try this, it is simple
SELECT id FROM `table_name` WHERE is_parent= 0

well, if
SELECT id FROM `table_name` WHERE is_parent= 0
fails, you may try:
SELECT id FROM `table_name` WHERE is_parent IN (1792,2304,1793,1794,2308....)
or:
SELECT id FROM `table_name` WHERE is_parent != 0

Related

Laravel eloquent Select statement set null column defualt value to 0 or blank [closed]

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 1 year ago.
Improve this question
I am creating a query and executing it in my project. I want to set null column value to 0 in select statement.
We need to set null to blank or zero. See below screenshot
I think you can use model casting, using "if" statement https://laravel.com/docs/8.x/eloquent-mutators#custom-casts
UPDATE table_nameSETcolumn_name = 0 WHERE column_name is NULL
Edit: You can add as many columns as needed by adding a comma ,

Query db with in exlusion [closed]

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
Trying to query db. I need to show all fields, but need to exclude one name that is in the db.
Example:
The db contains column 'marketer' when I try to query it I don't want marketer 'Tommy' but all the others. I have tried tried where clause with all the names and not working.
This is the query you're looking for
SELECT * FROM <table_name> WHERE marketer<>'Tommy';
use the 'where' to add your conditions
SELECT * FROM your_table WHERE marketer!='Tommy'
For your Reference
http://www.w3schools.com/sql/sql_where.asp

Query for products offer in mysql? [closed]

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 7 years ago.
Improve this question
I'm using
productinfo (`productId`, `productName`, `productPrice`, `productSaleprice`, `productImage`, `productLink`, `productColor`, `productSize`, `categoryId`, `sourceProductId`, `sourceId`)
where productinfo is table, And i display products on the basis of productPrice and productSaleprice.
At this moment I fetch all results and calculate everything in PHP like this:
$diff=$productPrice-$productSaleprice;
$result=($diff)/($productPrice/100);
My question is, is it possible to calculate the same things in MySQl without using PHP?
The result should be displayed in DESC Order
I think below SQL useful to you.
select `productId`, `productName`, productPrice, productPrice, productPrice-productSaleprice as diff ,
(productPrice-productSaleprice)/(productPrice/100) as result
from productinfo
where category= 5
order by result desc;
Thank you

Echo name of fields from MySQL table to web page [closed]

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
How do I display all field names from a MySQL table to a web page when I only know the table name?
Use the information_schema meta-DB:
SELECT COLUMN_NAME
FROM information_schema.TABLES
WHERE (TABLE_SCHEMA='Yourdb') AND (TABLE_NAME = 'Yourtablename')
In addition to #MarcB's suggestion, you can also do:
SHOW COLUMNS FROM table
http://dev.mysql.com/doc/refman/5.6/en/show-columns.html

Insert each result of an array into separate SQL rows? [closed]

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 have a query that is returning a different amount of user_id's each time it's run (based on the number of subscribers).
What I need to do is insert each of these user_id results into separate rows within a table along with a simple message of "new alert" in a separate column.
How could I possibly go about doing this? Would a for each loop work in this situation?
Try this:
INSERT INTO alert_table SELECT user_id, 'new alert' FROM ... WHERE ...
Use your own query, just prepend it with the INSERT INTO alert_table clause.

Categories