Assigning Specific Sub-Level Categories To All Members Via An SQL Command

Link: https://support.brilliantdirectories.com/support/solutions/articles/12000002543-assigning-specific-sub-level-categories-to-all-members-via-an-sql-command

The primary reason why you may need to apply this SQL command is:


1. If a customer has multiple sub-level categories with the same name, and wants to import members to specific sub-level categories. For example:


Parent 1: Tires


Sub-Sub Level: Cars, Trucks, Bikes


Parent 2: Wheels


Sub-Sub-Level: Cars, Trucks, Bikes


If you import members with the fields label "services", and assign "cars, trucks, and bikes" as the services offered, the system will have no way of knowing which set of sub-level categories to assign them to. This means that it will auto assign the first "cars" that it finds, regardless of it belong to the proper "parent" sub-level category. 


In order to ensure the proper sub-sub level categories are assigned to each member, you should omit "services" during the import process. We have attached a file that shows the wrong format. 




Since sub-level categories and sub-sub-level categories all get imported as "services", there is no way to tell the system which parent the sub-sub level categories should be imported under. In the screenshot above, all members will have the proper sub-level category selected (wheels or tires), but all members will have the sub-sub level categories belonging to "tires" selected, since these are the fist matches found. 


Once the members are imported into the database, please use the following SQL command to assign a specific set of "service_ids" to ALL members in the database. 


INSERT INTO rel_services( user_id, service_id )

SELECT user_id, 135

FROM  `users_data`


Important note: "135" represents service_id "135". You can only assign one service_id per command. To assign a different service_id to all members, replace "135" with whichever service_id you would like to assign. 


You can identify which service_id is linked to which category by referencing the "list_services" data table.