Jump to content
  • 0
Sign in to follow this  
vijay

Problem with SQL quire command.

Question

										UPDATE `storage` SET `nameid`=18546 WHERE `nameid` IN ('22556','3300','3301','3250','3251','22564');			

 

The above code is not working.

I just want to replace 22556','3300','3301','3250','3251','22564 items with 18546.

Any help would be grate, thanks!

Edited by vijay

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Just do that?

 

 

UPDATE `storage` SET `nameid`=18546 WHERE `nameid` = 22556; UPDATE `storage` SET `nameid`=18546 WHERE `nameid` = 3300;UPDATE `storage` SET `nameid`=18546 WHERE `nameid` = 3301;UPDATE `storage` SET `nameid`=18546 WHERE `nameid` = 3250;UPDATE `storage` SET `nameid`=18546 WHERE `nameid` = 3251;UPDATE `storage` SET `nameid`=18546 WHERE `nameid` = 22564;

Share this post


Link to post
Share on other sites
  • 0

@@Oxxy thanks, but i wanna do like 100+ items.

Here is the full code.


										UPDATE `storage` SET				`nameid`=18546 WHERE `nameid` IN				('22556','3300','3301','3250','3251','22564','22565','22566','22567','22568','22569','22570','22571','22573','22574','22575','22576','22577','22578','22579','22580','22581','22582','22583','22584','22585','22586','22587','22588','22589','22590','22591','22592','22593','22594','22595','22596','22597','22598','22599','22600','22601','22602','22603','22604','22605','22606','22607','22608','22610','22611','22612','22613','22614','22615','22616','22617','22618','22619','22620','22621','22622','22623','22624','22625','22626','22627','22628','22629','22630','22631','22632','22633','22634','22635','22636','22637','22638','22639','22640','22641','22642','22643','22644','22645','22646','22647','22648','22649','22650','22651','22652','22653','22654','22655','22656','22657','22658','22659','22660','22661','22662','22663','22664','22665','22666','22667','22668','22669','22670','22671','22672','22673','22674','22675','22676','22677','22678','22679','22680','22681','22682','22683','22684','22685','22686','22687','22688','22689','22690','22691','22692','22693','22694','22695','22696','22697','22698','22699','22701','22702','22703','22704','3400','3401','3403','3404','3405','3406','3407','3408','3409','3410','3411','3412','3413','3414','3415','3416','3417','3418','3419','3420','3421','3422','3423','3424','3425','3426','3427','3428','3429','3430','3431','3432','3433','3434','3435','3436','3437','3438','3439','3440','3441','3442','3443','3444','3450','3451','3452','3453','3454','3455','3456','3457','3458','3459','3460','3461','3462','3463','3464','3465','3466','3467','3468','3469','3470','3471','3472','3473','3474','3475','3476','3477','3478','3479','3480','3481','3482','3483','3484','3485','3486','3487','3488','3340','3341','3342','3343','3344','3345','3347','3348','3349','3350','3351','3352','3353','3354','3355','3321','3322','3323','3324','3325','3326','3327','3328','3356','3357','3358','3359','3360','3361','3362','3363','3364','3365','3366','3367','3368','3369','3370','3371','18076','18077','18078','18079','18080','18081','3346');			


I hope you get my point!

Share this post


Link to post
Share on other sites
  • 0

I guess you could use some programming to get your job done. You should have some basic knowledge to make your SQL statement via a simple C program for example:

 

#include <stdio.h>int main(void){int i,num_items;int items[] = {22556,3300,3301,3250,3251,22564,22565,22566,22567,    22568,22569,22570,22571,22573,22574,22575,22576,22577,22578,    22579,22580,22581,22582,22583,22584,22585,22586,22587,22588,    22589,22590,22591,22592,22593,22594,22595,22596,22597,22598,    22599,22600,22601,22602,22603,22604,22605,22606,22607,22608,    22610,22611,22612,22613,22614,22615,22616,22617,22618,22619,    22620,22621,22622,22623,22624,22625,22626,22627,22628,22629,    22630,22631,22632,22633,22634,22635,22636,22637,22638,22639,    22640,22641,22642,22643,22644,22645,22646,22647,22648,22649,    22650,22651,22652,22653,22654,22655,22656,22657,22658,22659,    22660,22661,22662,22663,22664,22665,22666,22667,22668,22669,    22670,22671,22672,22673,22674,22675,22676,22677,22678,22679,    22680,22681,22682,22683,22684,22685,22686,22687,22688,22689,    22690,22691,22692,22693,22694,22695,22696,22697,22698,22699,    22701,22702,22703,22704,3400,3401,3403,3404,3405,3406,3407,    3408,3409,3410,3411,3412,3413,3414,3415,3416,3417,3418,3419,    3420,3421,3422,3423,3424,3425,3426,3427,3428,3429,3430,3431,    3432,3433,3434,3435,3436,3437,3438,3439,3440,3441,3442,3443,    3444,3450,3451,3452,3453,3454,3455,3456,3457,3458,3459,3460,    3461,3462,3463,3464,3465,3466,3467,3468,3469,3470,3471,3472,    3473,3474,3475,3476,3477,3478,3479,3480,3481,3482,3483,3484,    3485,3486,3487,3488,3340,3341,3342,3343,3344,3345,3347,3348,    3349,3350,3351,3352,3353,3354,3355,3321,3322,3323,3324,3325,    3326,3327,3328,3356,3357,3358,3359,3360,3361,3362,3363,3364,    3365,3366,3367,3368,3369,3370,3371,18076,18077,18078,18079,    18080,18081,3346};// an int can take up different space on each computernum_items = sizeof(items) / sizeof(items[0]);// let's make the query stringprintf("Your query is: n");printf("UPDATE `storage` SET `nameid`=18546 WHERE `nameid` = %d", items[0]);for (i = 1; i < num_items; i++) {    printf (" OR `nameid` = %d", items[i]);}printf(";n");printf("Done.");scanf("%d",i);return 0;}

Compile&run it and you'll have your query. Remember to backup before applying, I may have made any sort of unexpected error on that.

 

P.S.: I didn't make use of the fact there are ranges of items that you could use to have an "OR ('nameid' > val1 AND 'nameid < val2)" type sentence and save OR checks.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.