By Netto on Thursday, 19 November 2020
Replies 17
Likes 0
Views 576
Votes 0
Hi, I need help with sql:
I want to reorganize my JEvents categories, the number is too large. But firstable I want to set some jev_tags in all events which have a special category.
For example: all events with the catid=160 should get the tag_id=15
Is there a way in phpmyadmin?

Thank you says
Jens.
Hi Jens

Not sure why which post was missed I may be able to write some SQL to do this but need to check if you are using multi-category events?

Geraint
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Geraint,

it would be very nice, thank you.
Yes, I'm using multi-caegory events

Best wishes for 2021
Jens.
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Try something like this


REPLACE INTO onjqe_jev_tageventsmap SELECT catmap.evid, 1 FROM onjqe_jevents_catmap AS catmap WHERE catmap.catid = 8


Explanation:

1. onjqe_ => my site/database prefix
2. 1 => the tag_id I am setting (taken from jev_tags table of the list of JEvents tags)
3. 8 => category id I want map to tag_id 1

I use REPLACE INTO instead of INSERT INTO to avoid duplicated entries

Backing up the jev_tageventsmap table before you start experimenting.

Good luck
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Hi Geraint,
thank you for the code. When I use it the category field in the event is empty. What is this code doing? It should replace the old cat id with the new one, isn't it? But in the table jev_tageventsmap there is no field named evid.
Something seems to be wrong. But I'm really not an expert.
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
A typo - sorry.


REPLACE INTO onjqe_jev_tageventsmap SELECT 1, catmap.evid FROM onjqe_jevents_catmap AS catmap WHERE catmap.catid = 8


The the select part fetches the event id of all events in category 8

The replace part inserts the values 1 and event id into the tags map columns tag_id and ev_id
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you. But after run the sql code there is no effect in the event. It's just the old category.
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
can you give me access to phpMyAdmin to take a look for you?
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you. Here are the access data.
Firstable I tried to change the category #181 to the category #160
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Are you wanting to change events from category 181 -> category 160 or to assign them a JEvents tag?

It its a tag which tag is it you want to assign to the evetns in category 181?
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
I want to change events the category 181 to category 160. Assigning the tags it's not neccessary, because all events are past events.
Thank You.
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
That is a little more complicated

This query

SELECT c1.*, c2.catid FROM `sk8j3_jevents_catmap` as c1 INNER JOIN `sk8j3_jevents_catmap` as c2 on c1.evid=c2.evid where c1.catid=181 AND c2.catid=160

says there are 4 events in both already so I'll need to avoid duplicates.

I'll have time to do this tomorrow
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
should be sorted now.
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you very much. Can you give me the sql code, please? I have a lot of more categories...
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Two steps

1,

SELECT c1.*, c2.catid FROM `sk8j3_jevents_catmap` as c1 INNER JOIN `sk8j3_jevents_catmap` as c2 on c1.evid=c2.evid where c1.catid=181 AND c2.catid=160

this gives the list of records that will cause a clash from step 2. in phpMyAdmin I removed the records where catid already exist for 160

2.

UPDATE `sk8j3_jevents_catmap` set catid=160 where catid=181


If you try step 2 before step 1 you may get an SQL error.
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you very much!
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Thank you for you help. I did for my next category both steps. After that I want do delete the old category - but it is not possible:
You are disabling a category with 287 events
Please deleted the associated events in this category first

What can I do? In which table there are these events?
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
Its possibible that the catid column of the #_jevents_event column needs to be updated too. Normally this is set at the same time as the category map table and represents the 'primary' category for the event.
·
4 years ago
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post