Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
1 answer
630 views

I need variable in parametrized view. CREATE VIEW my_new_view AS SELECT CampaignName, sentiment, -- **CASE WHEN variable** = sentiment THEN sentiment ELSE NULL END AS sentiment_match COUNT(CASE ...
dundi rajesh's user avatar
0 votes
0 answers
41 views

I'm trying to reuse the @FleetNumber variable to get the Truck's Trailer registration Number through the fleet number <fleetnumber>T eg.393T. The Trailer has the fleet number of the <...
Madeline Kallis's user avatar
0 votes
0 answers
13 views

I am running MySQL Community Server v5.7.40 and have 2 tables: "customers" and "events" created as follows: create table customers (customer_id int, name varchar(100), primary key (...
nick_j_white's user avatar
-1 votes
1 answer
37 views

$category = htmlspecialchars($_GET['category']); $sql = "(SELECT number FROM german WHERE german.category_german LIKE ".$category." ORDER BY number DESC ...
FreakyLord's user avatar
0 votes
1 answer
61 views

I want to display one paid status(1) column and then 3 unpaid(0) status column respectively. Paid status is taken based on Expirydate, the date greater than now is considered paid status and date ...
Jewel John's user avatar
1 vote
0 answers
152 views

I am using below block to fetch mysql variables. - name: Check for wsrep_cluster_status setting mysql_variables: login_user: '{{ mysql_root_user }}' login_password: '{{ mysql_root_pwd }}' ...
Srikanth Lingala's user avatar
-1 votes
2 answers
602 views

I have the following tables: Stocks id name amount 1 Pen 35 2 Cd 21 3 Bag 15 StockUnits id name include stockid 1 onepen 1 1 2 dozen 6 1 3 pocket 24 1 4 onecd 1 2 5 pocket 5 2 6 onebag 1 3 So how do I ...
Hamreen Ahmad's user avatar
0 votes
1 answer
507 views

Looking for a way to return a variable that can be used inside a IN-operator. My current result returns: 1,2,3, but I guess the variable should be more like this: '1','2','3' to be able to use it. ...
Aldo's user avatar
  • 963
-1 votes
1 answer
974 views

the error that I'm getting is " Must declare the scalar variable "@x"." I'm trying to declare a variable @x and make him a NVARCHAR(50) then id like to subtract an amount from it ...
roee oselka's user avatar
1 vote
1 answer
898 views

select Id,request_id,key_skill_id, ROW_NUMBER() OVER (PARTITION BY skill_id ORDER BY request_id,skill_id) sequence from report where id= x GROUP by request_id, ...
Narayan Pandey's user avatar
0 votes
1 answer
2k views

For STRICT_ALL_TABLES, MySQL returns an error and ignores the rest of the rows. However, because the earlier rows have been inserted or updated, the result is a partial update. To avoid this, use ...
INDIAN DECODER's user avatar
2 votes
1 answer
166 views

The goal is to variate price over a large range of numbers to be able to plot a figure. My current query returns one row with name and a default price. I tried adding an increment variable: select ...
Robertjvw's user avatar
1 vote
2 answers
82 views

I set a variable name for a table as lowercase: Set TGT_TABLE = 'tab_name'; however when i try to call it: select * from table($TGT_TABLE); I get an error: SQL compilation error: Object 'TAB_NAME' ...
OUMOUSS_ELMEHDI's user avatar
0 votes
1 answer
190 views

I have a query for comparing statement balances with expense records. I would like to make it a View, but it is using two variables, which you can't use in a View. It occurs to me that it should be ...
Jan Steinman's user avatar
0 votes
0 answers
39 views

I am trying to do something like this: SET @grade_id = (SELECT grade_id FROM grades_table WHERE grades = '1' AND sections = 'A'); SET @subject_id = (SELECT subject_id FROM subjects_table WHERE ...
Bhavika Choudhary's user avatar
0 votes
3 answers
3k views

Is there is a way to delete records using WHERE IN @VARIABLE? -- DEMO TABLE CREATE TABLE people ( id int AUTO_INCREMENT NOT NULL, name varchar(100), age int, active smallint DEFAULT 0,...
DevWL's user avatar
  • 19k
0 votes
0 answers
160 views

I am fetching data from an excelsheet using LOAD DATA INFILE statement and trying to evaluate the results before saving to a database. I need to be able to pass one of the fields from the excel as a ...
Peter's user avatar
  • 72
1 vote
1 answer
170 views

I'm trying to figure out how to call the column in the table where the column name matches the value of a declared variable. In this example, Tbl_B has columns labeled as DPS_YYYYMM such as '...
SusanD's user avatar
  • 143
0 votes
1 answer
114 views

I have a simple mysql table: CREATE TABLE `cont` ( `ID` int(11) NOT NULL, `Meeting_id` int(11) DEFAULT NULL, `member_name` varchar(20) NOT NULL, `cont_prod` varchar(20) NOT NULL, `...
Khalid Teli's user avatar
1 vote
1 answer
247 views

I'm trying to get the number of rows in a table or column and place that value inside an equation, like this: UPDATE myTable SET myCalculatedColumn = COUNT(*) / (@rownum:= 1 + @rownum) WHERE 0 = (@...
Normajean's user avatar
  • 1,313
0 votes
1 answer
827 views

I have a statement, select customer_id,count(customer_id), sum(total_price), date_time from the_order group by customer_id; The Result, cus1 15 437700 2021-04-23 cus2 1 12000 2008-5-9 ...
Aman Chaudhary's user avatar
0 votes
1 answer
200 views

Trying to do something very simple. Using If/Then, is there a way to run a separate Select statement based on the value of a variable? The function GetTotalActiveUnits() in the below code returns an ...
John's user avatar
  • 27
0 votes
1 answer
43 views

SET @last_nid=-1; SELECT vid, IF(@last_nid = nid, @last_status, 0) AS last_status, @last_status := status AS status, @last_nid := nid AS nid FROM node_field_revision ORDER BY vid; ...
chx's user avatar
  • 11.9k
-1 votes
2 answers
1k views

Consider the following procedure: CREATE PROCEDURE `getFoo`() BEGIN select 'bar' as foo; END; Once call-ed, it outputs: {"foo":"bar"} But what if getFoo is invoked within a ...
Constantin's user avatar
2 votes
1 answer
8k views

I've tried to set this by using SET VARIABLE but it said that have_query_cache is read-only mysql>SHOW VARIABLES LIKE 'have_query_cache'; +------------------+-------+ | Variable_name | Value | +-...
karver35's user avatar
4 votes
1 answer
5k views

I have a MySQL database in production and I am trying to calculate the optimised number to set the MySQL max_connections value to - Am I doing this correctly as my sums seem quite high to me. As far ...
Zabs's user avatar
  • 14.2k
0 votes
1 answer
304 views

So what I expect is for the first piece of code to find the table name then if that table name exists and is more than 3 days old drop that table. My issue with this code is that the code is not ...
Jessica Warren's user avatar
1 vote
1 answer
1k views

I use the SQL 'show variables like 'character%';' to show the character set in MySQL variables.I find a variable named 'character_set_database', I want to know the use of it. I get some info from the ...
huangjk5's user avatar
1 vote
1 answer
171 views

I have created MySQL query interpolation below in Workbench. The query was so fit to my needs except that I could not effect the "User Defined Variable" @var1/2/3 as my field aliases. I am ...
RickyBelmont's user avatar
0 votes
1 answer
441 views

I am trying to design a unit test that ensures that a message is bigger than a certain number of characters. My code is: EXEC tSQLt.NewTestClass 'TestMarketingEnoughRows'; GO CREATE OR ALTER ...
PolarVortex8's user avatar
0 votes
1 answer
38 views

i have a table with order_buyer_id as the id of transaction, createdby as the id of the buyer, createdAt as the date which transaction happen, and quantity as the weight of each transaction. on my ...
18Man's user avatar
  • 572
0 votes
1 answer
515 views

I have been trying to write a stored procedure that involves a user entering in the column they wish to store data in and then the data to be stored. So far this works but the column is hard coded. ...
Joe Nehl's user avatar
0 votes
2 answers
2k views

How do I create variables in MySQL that I can refer to in the same statement? Does this work for UPDATE and INSERT statements as well? I asked this because I got a lot of SQL text files where I ...
JPT's user avatar
  • 585
0 votes
1 answer
594 views

I have an Ansible playbook with this task.. --- - name: Set mysql_variable mysql_variables: variable: mysql_variable value: 2000 - name: Reload MySQL service: name: mysql state: ...
Sollosa's user avatar
  • 441
0 votes
1 answer
937 views

Here is my Table "assets" +----+----------------------------+-------+-----------+ | id | model | grade | warehouse | +----+----------------------------+-------+-----------+ | 1 |...
AZinkey's user avatar
  • 5,359
0 votes
1 answer
41 views

When I write code: SET @code = 'a123'; UPDATE my_table SET number = (number + 1) WHERE code = @code; it doesn't work correctly. But if I write code: UPDATE my_table SET number = (number + 1) WHERE ...
M. Feyz's user avatar
  • 359
1 vote
3 answers
111 views

I have a table. It has the following structure goods_receiving_items id item_id quantity created_at I am trying to fetch rows against which have the following conditions Has one item_id When the sum ...
Abid Suleman Ahmed's user avatar
0 votes
2 answers
169 views

I am looking into the following mysql: select num, @record, case when @record = num then @count:=@count+1 when @record <> @record:=num then @count:=1 end as n from Logs ,(select @...
Edamame's user avatar
  • 25.6k
0 votes
1 answer
32 views

I am looking into the following sql codes, trying to understand but confused: What does the query actually do when we put the two tables together? What's the difference between this and joining the ...
Edamame's user avatar
  • 25.6k
1 vote
0 answers
151 views

Mysql row-based binary logging seems to have a different behaviour when grouping rows changes in some versions of mysql. Let's assume the following statement update three rows: UPDATE table_name ...
Leonardo Kuffo's user avatar
0 votes
1 answer
558 views

Sadly, we do auditing through inline comments in SQL queries, like this: begin transaction; EXEC someStoredProcedure; --this was executed by Bob commit transaction; I'm trying to automate it by ...
Andrew Tsay's user avatar
  • 1,983
-1 votes
1 answer
29 views

I have the following SQL which is not working how I thought it would. SET @runtot:=0; select q1.week, (@runtot := @runtot + cast(q1.flying_hours as SIGNED)) as flying_hours, q1.flying_hours as ...
PrestonDocks's user avatar
  • 5,527
3 votes
1 answer
1k views

I have a query like below to remove from a table column certain substrings which begin and end with particular substrings: UPDATE om_posts SET post_content=REPLACE(post_content, SUBSTRING( ...
geochanto's user avatar
  • 1,022
6 votes
6 answers
3k views

I am using SET GLOBAL <variable> = <value> to modify dynamic settings in mysql and I am wondering if there is some way to get the default value for each variable? For instance, if I use ...
Cyclonecode's user avatar
  • 30.4k
0 votes
1 answer
198 views

Is there any way to get all system variables that can be modified during runtime? I have tested using SHOW VARIABLES but this returns all variables and not only the one that can be changed during ...
Cyclonecode's user avatar
  • 30.4k
1 vote
2 answers
2k views

I have two sql queries. But in Java I can't set variables. I tried to summarize it to one query. But that not works, because the sql syntax is wrong. SET @rn = 0; SELECT * FROM (SELECT t.id, @rn :=...
Alex K.'s user avatar
  • 21
0 votes
1 answer
542 views

I wish to add data to the existing variable which I created in Mysql. set @variable = select * from b where b.id = 35; @variable = select * from b where b.name = "dheeraj"; How can I go ahead with ...
Dheeraj Gupta's user avatar
0 votes
1 answer
1k views

in /etc/mysql/my.cnf: [mysqld] log_bin=mysql-bin binlog_format=ROW server-id=11 then on mysql client: mysql> show variables like '%binlog%'; +-----------------------------------------+------------...
Jack Ma's user avatar
  • 317
-1 votes
3 answers
58 views

See below and test here. I've been pulling my hair out over this for a couple of hours now. I've searched many posts and as best I can tell everything is correct. I'm having trouble with the IF ...
mal's user avatar
  • 3,302
0 votes
1 answer
31 views

I have the following query select count(t1.guid) from table t1 where t1.id=X; X is a result-set from this query select ID from table t2 where t2.flags=65537; The above query returns 84 results, ...
Nikola Pavlovic's user avatar