Skip to main content

All Questions

Filter by
Sorted by
Tagged with
2 votes
0 answers
55 views

SQL conditional select and conditional where

I have a problem creating a view or a select statement. the problem could be due to poor design so any suggestions could help. I will try to simplify the design as follows: A service table, service....
Haz's user avatar
  • 23
0 votes
2 answers
49 views

MySQL: Group timeseries conditionally

I'm trying to bring a time series sum grouped by date, week or month, depending on the total number of dates. For instance, if there is up to 30 days, group the sum by date, if there is between 31 and ...
Valentoni's user avatar
  • 328
-1 votes
2 answers
93 views

Understanding a weird SQL clause

While learning some SQL, I stumbled upon this seemingly incorrect clause: SELECT item FROM inventory WHERE 20 >= price < 500; The query does not result what was intended and should look like ...
pyte's user avatar
  • 59
1 vote
2 answers
187 views

Mysql: Conditionally Create a stored procedure

How would I conditionally create a stored procedure in MySQL? I only want the stored procedure created if another condition is true. SELECT COUNT(*) INTO @version FROM version WHERE version = '9'; IF ...
Donavon Lerman's user avatar
0 votes
1 answer
108 views

Recursion in mysql filling children from parent, if parent is not null

I have a table made after joining 2 tables, which produces a recursive table. Now I want to add an extra column CalculatedDiscount and fill empty discounts from higher to lower when lower groups are ...
jan-peter Poppe's user avatar
0 votes
1 answer
688 views

insert if row count is 0

The following query works in MySQL: INSERT INTO `test`.`address_tab1` (`city`,`street_name`,`pincode`) SELECT 'mycity1', 'mystreerName1', '4855881' where (SELECT COUNT(*) FROM `test`.`address_tab1`) ...
Nazir's user avatar
  • 243
-1 votes
2 answers
55 views

Insert value through procedure in a table by mysql

I want to insert values into a table by using a procedure. I have 2 tables sales and products; in the product table I have columns id, product_name,product_price, product_quantity and in sales table I ...
Kinza khan's user avatar
0 votes
2 answers
78 views

Insert INTO tableA (...) Values(...) Where id from tableB

Basicly I have a table for persons data- tb_person (name,date&time,person_id etc) and other table for meals- tb_meals(meal_id,meal type etc) , I want to insert a value in meal in tb_meals where ...
cdb's user avatar
  • 1
-1 votes
2 answers
87 views

How do I create a SELECT conditional in MySQL where the conditional is the character length of the LIKE match?

I am working on a search function, where the matches are weighted based on certain conditions. One of the conditions I want to add weight to is matches where the character length of the query string ...
Llewen's user avatar
  • 31
-2 votes
1 answer
30 views

Show values from a column, using values from another column as conditions

I have a table called "fisketur" that looks like this: I have a table called "plads" that looks like this: How can I make it so that I only get the values from "plads.navn&...
Robin Hansen's user avatar
0 votes
1 answer
38 views

Order by first non-null result that comes from two different columns

I want to browse through all values of two columns in a table: if the value in column 1 is not null, select it, otherwise select the value in column 2 instead. then sort the final result in ...
Bachir Messaouri's user avatar
1 vote
2 answers
38 views

Mysql Substr index and multiple group by conditions

I'm trying to get the totals of a table grouped by names that are similar. Here is my test mysql: CREATE TABLE IF NOT EXISTS aa ( clicks INT NOT NULL, locn varchar (30) NOT NULL ) ...
user3052443's user avatar
0 votes
1 answer
100 views

How to get a multiple count inside a select with multiple AND conditions

Im trying to do this count but its returning false ! It only works with just one "AND" condition. public function get(int $id, int $count) { $id5 = $id4 = $id3 = $id2 = $id1 = $id; $...
Jeferson's user avatar
0 votes
1 answer
33 views

Run A Conditional Check On Data From One Table, Prior To Database Submission On Another Table - MySQL

I have a MySQL table that works as a pivot/linking table and it initially contained two columns, both of which were foreign keys. These two columns were a board_id column and an image_id column. This ...
paulo77's user avatar
  • 174
0 votes
2 answers
29 views

Mysql data extraction

I have a table called deals, it has records like this for example id deal_ref objectname status 1 1234 tom correct 2 1234 tom correct 3 1234 jerry wrong 4 1234 ...
WeegyGW's user avatar

15 30 50 per page
1
2 3 4 5
46