Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1

    Default HELP! Conditional Statements in MYSQL


    mga bro... naa ko'y gusto i query sa database that requires some conditions.. ang problema kay d ko kamao unsaon pag gamit ug conditions sa MYSQL... mao ni ako query:

    select script.script_id, if(script.script_id == and script_error.script_id then return 'YES' else return 'NO') as ERROR from script, script_error

    TABLES:

    script ( script_id )
    script_error ( script_error_id, script_id )

    unsaon ni mga bro... kahibaw ko saup ako query peru d ko kahibaw unsaon para ma sakto... gusto ko na if naay pareha ug script_id between sa script ug script_error tables kay YES ang value na i return... else NO... tabang... lamat daan....

  2. #2
    Use the iif() function.

    select script.script_id,
    iif(script.script_id = script_error.script_id, 'YES', 'NO') as ERROR
    from script, script_error

    Does the two tables in your select statements needs to be joined?
    If not the resulting set will be very large.

  3. #3
    MR. COLD FUSION.... ur the man... hahah... lamat kaau bai ha.... peru ask lang ko ha... unsay advantage kung mag join ka?? weak jud kaau ko anang JOIN statements bro.... la pa kaau ko kasabot ana... ang simple join ra jud ako nasabtan ug maau... bsag nag basa nku about anang LEFT JOIN, RIGHT JOIN... d kaau nku pa grasp ang idea.... pwede pa tudlu?? in vernakular?? ahha.. or pwede sad kanang mu gamit ka ug mga words na dali ra masabtan.... hahaha... lamat jud kaau bro.. daku kaau ka ug tabang...

  4. #4
    It's difficult to explain.
    Joins are used with tables that are normalized.
    Read first about it here Database normalization - Wikipedia, the free encyclopedia .

  5. #5
    HELP again at sql queries...

    PROBLEM:

    select code from scripts where script_id = 00001;

    //if code has a length of 200 characters....
    gusto lang unta nku makuha na characters sa code kay 50 characters lang....

    unsaon ni nku pag magic sa sql...

  6. #6
    Elite Member
    Join Date
    Aug 2008
    Posts
    1,053
    Blog Entries
    1
    why not use LEN or LENGTH functions? depending in your platform like MySQL, Oracle, PostGres then use WHERE clause...?

  7. #7
    bro..

    try daw adto na dauga sa imong form.... lets say if ang script_id=00001
    dapat unta ang i return sa code mga 1000 ang iyang length....

    im just assuming na imo gamit vb.net .... if ever... adto na lang dauga didto sa form....

    gamit na lang ka ug mga built in functions....

    if ever dili .... pasensya... hehehehehe


    bitaw... try lang na ang return value nga gikuha nato sa database adto na lang na sa front end

  8. #8
    ok na mga bro... na magic na nku ang SQL statements... here is my magic.... hhahaha...

    select substring(code,1,50) as LimitedCharCode from scripts where script_id = 00001;

    gamit ra nku ang substring function....

    syntax: substring(string, beginning offset, ending offset)
    NOTE: if you want to start at the beginning, beginning offset should be one (1) kay i think index zero(0) does not exist... tried using zero and there was no output... tried using one and my magic worked.. hahah...

  9. #9
    Quote Originally Posted by ben77 View Post
    bro..

    try daw adto na dauga sa imong form.... lets say if ang script_id=00001
    dapat unta ang i return sa code mga 1000 ang iyang length....

    im just assuming na imo gamit vb.net .... if ever... adto na lang dauga didto sa form....

    gamit na lang ka ug mga built in functions....

    if ever dili .... pasensya... hehehehehe


    bitaw... try lang na ang return value nga gikuha nato sa database adto na lang na sa front end


    lamat sa idea bro.. peru mas nindot jud bro kung daugon nmu sa SQL... kay mas lesser ang code lines na i process... so mas paspas mu compile imo program... so kung ma dala pa gani ug magic sa SQL.. magic-kon jud... peru d gani... go to d last resort... hehehe...

  10. #10
    hehehehe....


    bitaw sad...


    try na nako pod ang imo gamit na substring...


    thanks for the tip... magamit ra nya na nako...

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. help, im stuck! in PHP programming.
    By emailroy2002 in forum Programming
    Replies: 16
    Last Post: 07-08-2010, 11:43 PM
  2. HELP: in MySQL query
    By rastaman81 in forum Programming
    Replies: 19
    Last Post: 01-23-2009, 09:43 PM
  3. Replies: 5
    Last Post: 10-06-2006, 08:07 AM
  4. gOsh help me...Trouble in LOVE...
    By witty_pretty in forum "Love is..."
    Replies: 2
    Last Post: 09-06-2006, 09:39 PM
  5. Replies: 32
    Last Post: 02-24-2006, 10:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top