Search Results

Search found 3 results on 1 pages for 'dashiell0415'.

Page 1/1 | 1 

  • postgres counting one record twice if it meets certain criteria

    - by Dashiell0415
    I thought that the query below would naturally do what I explain, but apparently not... My table looks like this: id | name | g | partner | g2 1 | John | M | Sam | M 2 | Devon | M | Mike | M 3 | Kurt | M | Susan | F 4 | Stacy | F | Bob | M 5 | Rosa | F | Rita | F I'm trying to get the id where either the g or g2 value equals 'M'... But, a record where both the g and g2 values are 'M' should return two lines, not 1. So, in the above sample data, I'm trying to return: $q = pg_query("SELECT id FROM mytable WHERE ( g = 'M' OR g2 = 'M' )"); 1 1 2 2 3 4 But, it always returns: 1 2 3 4

    Read the article

  • php nested for statements?

    - by Dashiell0415
    I'm trying to process a for loop within a for loop, and just a little wary of the syntax... Will this work? Essentially, I want to run code for every 1,000 records while the count is equal to or less than the $count... Will the syntax below work, or is there a better way? for($x = 0; $x <= 700000; $x++) { for($i = 0; $i <= 1000; $i++) { //run the code } }

    Read the article

  • postgres syntax question for OR?

    - by Dashiell0415
    The first one below works, but, just wanted to see if there's a better way... If I'm trying to find all records that start with 'C' with either a flag of 2 or a status of 9, do I need to incorporate the 'C' criteria twice? i.e., "SELECT * FROM mytable WHERE name like 'C%' AND flag = 2 OR name like 'C%' AND status = 9" Or, is there a way quicker way to write it so that I only need to set 'C%' once?

    Read the article

1