Questions tagged [SQL] (4020)

1
answer

How to make an sql query with multiple join th?

Good afternoon. Help to make a correct SQL query with multiple join th There are tables users [id, name, avatar] wall [id, user_id, text] wall_likes [id, user_id, wall_id] First I had to write wall of a particular user + to connect with users that would get the name and avatar. Did SELECT i.*, u.name, u.avatar FROM the wa...
julien24 asked April 18th 20 at 12:45
1
answer

How to compare the results of the subqueries?

Here is an example query that retrieves the number of employees with education, without it, and all together: SELECT (SELECT COUNT(temployee.*) FROM temployee,teducation WHERE dfdepartment = tdepartment.dfobj AND teducation.dfemployee = temployee.dfobj ) AS edu, (SELECT COUNT(*) FROM temployee WHERE dfdepartment = td...
Katlynn.Hoppe92 asked April 18th 20 at 12:33
1
answer

How to make a request?

Good afternoon. There are two tables, they have same columns, I need to get records from two tables in accordance with the incoming data. Do this: SELECT name,phone,address FROM `psn` UNION SELECT name,phone,address FROM `office` WHERE `name` = '$zapros' OR `phone` LIKE '%$zapros%' OR `address` LIKE '%$zapros%' In the end, ...
Harvey.Treutel12 asked April 18th 20 at 12:33
2
answers

How to display query result in one column in sql?

good day, I made a query in database and got my desired values, but I need to withdraw all count in one column, each on its own line, how can I do that?
nathaniel_Schneider asked April 18th 20 at 12:21
1
answer

How can I make some count c different filters in sql?

Good day, our database has multiple records, I want to get the number of records in which the column status is equal to table.status = 'active', and in the same query want to get the number of records in which the column status is equal to table.status = offline, how best to do this?
karlie asked April 18th 20 at 12:20
1
answer

How to facilitate the selection by attributes?

select t1.value_int y,t2.value_int m,t3.value_int d t4.utm_source value_string, k.value_int kind_int, i.count cnt from stat_item_attrs k stat_item left join i on i.id = k.item_id stat_item_attrs inner join t1 on t1.item_id = k.item_id and t1.attr_type = 1/*y*/ inner join t2 on t2 stat_item_attrs.item_id = k.item_id and t2.a...
Green.Wa asked April 18th 20 at 12:15
2
answers

How to use SELECT into ALTER TABLE?

There is one query that returns the following table There is a second select that returns a table The result is required in the form Combine selects in one did not work. To solve the problem I decided to use a temporary table. How to join 2 tables + fill with zeros in the missing values ?
margret_Kessler asked April 18th 20 at 12:14
2
answers

How to use a nested JOIN with GROUP BY?

Table- CREATE TABLE help (user_id INT, film_id INT, price INT, source VARCHAR(10)); Which contains the following data INSERT INTO help(user_id, film_id, price, source) VALUES(1, 3,52, 'netflix'), (2, 5,100, 'amazon'), (1, 6,10, 'netflix'), (5, 2,51,'amazon'); Where user_id - user ID, film_id - ID film, price and scource pla...
catharine_Schinner asked April 18th 20 at 12:12
2
answers

How to use a variable from the GROUP BY in the subquery?

Table - CREATE TABLE help (user_id INT, source VARCHAR(10), INT watch, INT download); With this content: INSERT INTO help (user_id, source, watch, download) VALUES (1, 'netflix', 1, 0), (2, 'netflix', 1, 0), (3, 'amazon', 1, 1), (1, 'amazon', 1, 1), (2,'ivi', 1, 0), (1, 'netflix', 1,1); The table contains the data of a "cha...
ivory_West95 asked April 16th 20 at 11:21
0
answer

Massively to set the attributes of images in content WordPress?

The website for the WP images in the records inserted in the content. You need all records for each image add the alt and title according to the principle: the name of the recording stage 1, the name of the entry phase 2, the name of the entry to stage 3... I now see 3 options: 1) the Existing plugin (the search for somet...
Russel.Davis41 asked April 16th 20 at 11:13