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 need to write a query which need to replace email result by 0 when it's null
UPDATE tblName SET email = 0 WHERE email is null;
Use the ifnull() function:
ifnull(email,"0")
You can use the coalesce function:
SELECT COALESCE(email, '0') FROM some_table
Related
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 12 months ago.
Improve this question
I have table like this, and i want to output the result like output table, can anyone tell me how to do it, in MySQL
You can use left join like so :
SELECT tb_session.SESSION AS SESSION, tb_class.CLASS AS CLASS from tb_schedul LEFT JOIN tb_session ON tb_schedule.ID_SESSION = tb_session.ID LEFT JOIN tb_schedul.ID_CLASS = tb_class.ID
Good morning, you can use LEFT JOIN
try it:
SELECT tb_session.SESSION, tb_schedul.ID_CLASS FROM tb_session LEFT JOIN tb_schedul
ON tb_session.ID = tb_schedul.ID_SESSION;
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 1 year ago.
Improve this question
I have a table in SQL Server where a row contains a Json column - something like this:
ResponseText
RequestId
{"LosUnqCod":0,"LosMidId":23}
96173722
{"LosUnqCod":1,"LosMidId":5}
96173721
I want to have a table in this shape:
LosUnqCod
LosMidId
RequestId
0
23
96173722
1
5
96173721
how to open this json?
Hi every body I found my answer and want to share with anyone who has the same issue as I does
SELECT
reqTbl.LosUnqCod ,
a.RequestId
FROM [dbo].[a] CROSS APPLY
OPENJSON( dbo.a.responsetext)
WITH (
LosUnqCod nvarchar(50)
) AS reqTbl
You don't have to use OPENJSON if you only have one JSON object (not an array) per SQL row, you can use JSON_VALUE instead:
SELECT
JSON_VALUE(a.responsetext, '$.LosUnqCod') LosUnqCod,
JSON_VALUE(a.responsetext, '$.LosMidId') LosMidId,
a.RequestId
FROM [dbo].[a];
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 3 years ago.
Improve this question
I have a table with a column in which are inserted timestamps.
exactTime : ' 2017-12-17 05:00:12 ' and i want to change this format into '2017-12-17 05:00'
i would need some help with this .
You could use date_format for this.
select date_format(your_date,'%Y-%m-%d %H:%i')
from your_table;
Resource
You can truncate to the nearest minute using:
select str_to_date('2017-12-17 05:00:12', '%Y-%m-%d %H:%i')
To actually output without seconds, you need to convert back to a string. Or just use string operations:
select left('2017-12-17 05:00:12', 16)
SELECT date_format('2017-12-17 05:00:12','%Y-%m-%d %h:%i')
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 3 years ago.
Improve this question
Below is the code failing in Hive:
(Alias at 6:5 (END) is not recognized)
INSERT INTO WRKT_REGULATORY_COMPONE_RECLASS
select
case
when WRKT_REGULATORY_COMPONENT_FINAL.REVENUE_FLAG != 'Y'
AND WRKT_REGULATORY_COMPONENT_FINAL.EXCLUDED_FLAG = 'Y'
THEN WRKT_REGULATORY_COMPONE_RECLASS.EXECUTION_ORDER = '1'
END
FROM WRKT_REGULATORY_COMPONENT_FINAL
this one: THEN WRKT_REGULATORY_COMPONE_RECLASS.EXECUTION_ORDER = '1' is wrong
after THEN it should be literal 1 or column
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 9 years ago.
Improve this question
I have 3 mysql queries in php (one for each category/widget), all 3 queries together should output 3 * 6 = 18 results. So if one query returns less, more results from the other queries should be used.
How can i do that? Thanks.
Instantiate 2 variables , keep count of selected rows and execute query using these counters
for example this will be your first query execiton
$default = 6;
$limit= $default;
$some_result = mysql("SELECT * FROM table LIMIT $limit");
then you can use this for every query-limit
$limit = $limit - count($some_result) + $default;