Questions tagged [mysql-select-db]
74 questions
0
votes
0 answers
select from same value mysql 5.7
i have 2 tables, this is my fiddle https://dbfiddle.uk/?rdbms=mysql_5.7&fiddle=7009f83d39d688e38aceb781b7fdc903
CREATE TABLE users (
ID int(10) PRIMARY KEY NOT NULL,
email varchar(255));
CREATE TABLE order_match_detail (ID int(10) PRIMARY…

18Man
- 572
- 5
- 17
0
votes
1 answer
put order by in right place mysql
i have query like this
SELECT COALESCE(p.name, 'total') AS `product name`,
SUM(omd.quantity) AS `Qty(kg)`,
SUM(omd.quantity) / any_value(total_sum) * 100 AS `Qty(%)`,
COUNT(om.id) AS `COunt Order`,
COUNT(om.id) /…

18Man
- 572
- 5
- 17
0
votes
1 answer
exists and no exists mysql
i have data dummy like this
CREATE TABLE A ( users_id INT);
INSERT INTO A VALUES (1), (2), (3), (4);
CREATE TABLE B (users_id INT);
INSERT INTO B VALUES (2), (3), (4), (5);
CREATE TABLE C (users_id INT);
INSERT INTO C VALUES (3), (4), (5),…

18Man
- 572
- 5
- 17
0
votes
1 answer
What will be the query for the following query?
SELECT s.subject_id
, s.subject_name
, t.class_id
, t.section_id
, c.teacher_id
FROM school_timetable_content c
JOIN s
ON c.subject_id = s.subject_id
JOIN school_timetables t
ON t.timetable_id = c.timetable_id
…

Student
- 25
- 2
- 11
0
votes
0 answers
how to count properly mysql version 5.8
so i have a query like this :
SELECT * FROM my_db.my_order where product_id = 395 order by id desc;
and the output of this table is like this
+----------+----------+----------+---------------------+------------+--------+
| order_id | buyer_Id |…

18Man
- 572
- 5
- 17
0
votes
2 answers
How to get joined entrys last when grouping by some columns
my table is filled with private messages
if i GROUP BY to_id i just get the oldest entry
i need the newest entry first
here is what i tried...
SELECT t1.date
, t2.nick
, t1.to_id
, t3.message
, xis_checked ,COUNT(*) AS subject
…

Asario
- 33
- 1
- 1
- 7
0
votes
1 answer
how to selected data based on several conditions mysql
i have a table called my_table like this
+------------+--------+--------+
| product | type_1 | type_2 |
+------------+--------+--------+
| Banana | A1 | B1 |
| Banana | B1 | B2 |
| Watermelon | A | B3 |
| Orange …

18Man
- 572
- 5
- 17
0
votes
1 answer
how to selected data based on condition null or not null mysql 5.7
i have table called my_table like this
+------------+-------+-------+
| product | type1 | type2 |
+------------+-------+-------+
| Banana | NULL | A1 |
| Grape | NULL | B1 |
| Watermelon | A | A1 |
| Orange | B |…

18Man
- 572
- 5
- 17
0
votes
1 answer
count based on conditions mysql 5.7
i used mysql version 5.7, i have a table production for every product, amount, and using many expeditions like this
+---------+-----------------+------+--------+---------+
| Product | Type_Expedition | Pack | Amount | Weight…

18Man
- 572
- 5
- 17
0
votes
1 answer
count wthout invalid use group of function mysql
I have a table like this,
CREATE TABLE order_match
(`order_buyer_id` int, `createdby` int, `createdAt` datetime, `quantity` decimal(10,2))
;
INSERT INTO order_match
(`order_buyer_id`, `createdby`, `createdAt`, `quantity`)
VALUES
…

18Man
- 572
- 5
- 17
0
votes
1 answer
how to find out time difference (on day) for every transaction on each users using mysql
I have a table like this:
CREATE TABLE test (
ID SERIAL PRIMARY KEY,
user_id INT,
createdAt DATE,
status_id INT
);
INSERT INTO test VALUES
(1, 12, '2020-01-01', 4),
(2, 12, '2020-01-03', 7),
(3, 12, '2020-01-06', 7),
(4, 13,…

18Man
- 572
- 5
- 17
0
votes
0 answers
why my percentage doesnt count 100% mysql
i have a fiddle just like this
CREATE TABLE sales(
id_order VARCHAR(50) NOT NULL,
createdAt datetime NOT NULL,
sale DECIMAL(14,2) NOT NULL,
id_location varchar(50) NOT NULL,
createdby varchar(50) NOT NULL,
order_status_id…

18Man
- 572
- 5
- 17
0
votes
1 answer
MySQL SELECT combined with preg_match PHP
I have a SELECT that compare if there is an answer for a certain question for an account
SELECT * FROM questions WHERE questions.id NOT IN (SELECT answers.qid FROM answers where answers.account = '$account')
Then in the while, I have a preg_match…

lStoilov
- 1,256
- 3
- 14
- 30
0
votes
2 answers
How to fix mysql select command giving wrong result after the update in another db connection?
I have taken two mysql db connections using python MySQLdb module namely db and db1. The first connection is used to read a table and the second connection is for updating the table.
The following are the sequence of code that I have used.
1 : Read…

mcv
- 45
- 2
- 10
0
votes
2 answers
CMS made simple: using mysql_select_db($dbname); messes up everything
hi im fairly new to cms made simple and ive stumbled upon a problem thats beyond me, my coad is

Umer Hassam
- 1,332
- 5
- 23
- 42