What error are you getting?

|
Gunnyvenkat 2022-07-05 20:04:54
Thanks you soo much swapnil
Gunnyvenkat 2022-07-05 20:05:01
I have another question
Gunnyvenkat 2022-07-05 20:13:25
I need where event is optin and confirm both then optin is first and confirm is second based on time
Swapnil 2022-07-05 20:25:06
Gunnyvenkat 2022-07-05 20:13:25
I need where event is optin and confirm both then optin is first and confirm is second based on time

Use the concept of row number or case statement like when optin then 1
when confirm then 2

Gunnyvenkat 2022-07-05 20:26:14
Find user_id which contains both optin and confirm but, when sorted by time, optin need to be first and then confirm need to come
Gunnyvenkat 2022-07-05 20:26:24
This is my question
Swapnil 2022-07-05 20:46:55
Gunnyvenkat 2022-07-05 20:26:14
Find user_id which contains both optin and confirm but, when sorted by time, optin need to be first and then confirm need to come

with cte_event as (
select *,
case when event = ‘optin’ or event =’confirm’ then ‘Y’
else null
end as filter
from test),
cte_cnt as (
select user_id,
count(1)
from cte_event
where filter is not null
group by user_id
having count(1) > 1)
select a.*
from test a
join cte_cnt b on a.user_id = b.user_id
where a.event in (‘confirm’,’optin’)
order by a.user_id,a.time

Kiran Kumar 2022-07-05 20:47:49
Doubt..??
Kiran Kumar 2022-07-05 20:48:35
Php to database connection..?
Kiran Kumar 2022-07-05 20:52:17
Html, php and database connected successfully but data not insterted into database table..??
Saikiran Cheviti 2022-07-05 20:52:24
Is this answererd…???
Saikiran Cheviti 2022-07-05 20:53:01
Anyway will answer this as I have faced this recently.
Saikiran Cheviti 2022-07-05 20:54:17
Just login to RDS CONSOLE and go to option group from there you can set this parameter =1 then save
Alejandro 2022-07-05 20:54:55
Saikiran Cheviti 2022-07-05 20:52:24
Is this answererd…???

No, it wasn’t answered, but i can fix it doing exactly that on the rds console.

Saikiran Cheviti 2022-07-05 20:54:56
And check it from the putty or any other tool it will be enabled
Saikiran Cheviti 2022-07-05 20:55:56
Yes we can set this from RDS console because rdsadmin in MySQL have the super user privilege
Saikiran Cheviti 2022-07-05 20:56:14
Alejandro 2022-07-05 20:54:55
No, it wasn’t answered, but i can fix it doing exactly that on the rds console.

👍🏻👍🏻👍🏻👍🏻

Luis 2022-07-05 21:45:27
mysql_en-22520.jpg
Where is the error pls
Swapnil 2022-07-05 22:04:13
Luis 2022-07-05 21:45:27
Where is the error pls

What error are you getting ?

Luis 2022-07-05 22:06:00
Says there is an error near UPDATE
Luis 2022-07-05 22:07:32
mysql_en-22523.jpg

Gunnyvenkat 2022-07-05 22:07:54
Swapnil 2022-07-05 20:46:55
with cte_event as (
select *,
case when event = ‘optin’ or event =’confirm’ then ‘Y’
else null
end as filter
from test),
cte_cnt as (
select user_id,
count(1)
from cte_event
where filter is not null
group by user_id
having count(1) > 1)
select a.*
from test a
join cte_cnt b on a.user_id = b.user_id
where a.event in (‘confirm’,’optin’)
order by a.user_id,a.time

I’m getting errors

Swapnil 2022-07-05 22:08:37
In the 2nd update it seems you are using wrong column name from cte.
It shoudl be can not can1
Gunnyvenkat 2022-07-05 22:09:07
Swapnil 2022-07-05 19:50:48
That was not mentioned explicitly in the requirement.

Anyway try below query

select distinct *
from test
where user_id not in
(select distinct user_id
from test
where event = ‘confirm’)
and event = ‘optin’

This working fine

Gunnyvenkat 2022-07-05 22:09:25
Swapnil
Gunnyvenkat 2022-07-05 22:09:46
Swapnil 2022-07-05 20:46:55
with cte_event as (
select *,
case when event = ‘optin’ or event =’confirm’ then ‘Y’
else null
end as filter
from test),
cte_cnt as (
select user_id,
count(1)
from cte_event
where filter is not null
group by user_id
having count(1) > 1)
select a.*
from test a
join cte_cnt b on a.user_id = b.user_id
where a.event in (‘confirm’,’optin’)
order by a.user_id,a.time

I’m getting errors for this swapnil

Swapnil 2022-07-05 22:09:54
Gunnyvenkat 2022-07-05 22:09:46
I’m getting errors for this swapnil

what erroe ?

Swapnil 2022-07-05 22:11:32
Luis 2022-07-05 22:07:32

May be ; after END is required

Luis 2022-07-05 22:14:41
May be ; after END is required
Luis 2022-07-05 22:14:41
It’s not the semicolon. The query is fine, the error is generated un the UPDATE.b
Gunnyvenkat 2022-07-05 22:17:35
mysql_en-22533.jpg
This is the table
Gunnyvenkat 2022-07-05 22:18:46
mysql_en-22534.jpg

Swapnil 2022-07-05 22:21:09
Gunnyvenkat 2022-07-05 22:18:46

may be some copy paste issue

Swapnil 2022-07-05 22:22:17
Luis 2022-07-05 22:07:32

Below is syntax of multi table update in MariaDB

UPDATE tab1, tab2 SET tab1.column1 = value1, tab1.column2 = value2 WHERE tab1.id = tab2.id;

Swapnil 2022-07-05 22:22:53
Swapnil 2022-07-05 22:21:09
may be some copy paste issue

Between select * and case there has to be comma

|