vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| In the following drupal table 'webform_submitted_data' the date 12/8/2007 is specified via 3 records ie: 2 1176718828 0 12 2 1176718828 1 8 2 1176718828 2 2007 I need to be able to select a sid that value matches a certain date. In the above example the sid value would be '2' if I wanted to select with date '12/8/2007'. I was wondering if there was a mysql (4.1.21- standard) SQL statement I could use select all the distinct sid values that match a certain date. The following is an example of a 'webform_submitted_data' table: sid cid no data 2 1176015743 0 alison@mailaby.com 2 1176015500 0 alison 2 1176015691 0 money 2 1176718828 0 12 2 1176718828 1 18 2 1176718828 2 2007 2 1176851105 0 1 2 1176851105 1 8 2 1176851105 2 2008 2 1177590862 0 Cheapest flights please 7 adt 6 chd 3 1176015743 0 ijwuishwe@mnqashiu 3 1176015500 0 james 3 1176015691 0 hogh 3 1176718828 0 4 3 1176718828 1 5 3 1176718828 2 2008 3 1176851105 0 4 3 1176851105 1 26 3 1176851105 2 2008 3 1177590862 0 Cheapest easter seats please 4 1176015743 0 jasnbuighe@kjnasiuh 4 1176015500 0 david 4 1176015691 0 wings 4 1176718828 0 12 4 1176718828 1 8 4 1176718828 2 2007 4 1176851105 0 12 This is a drupal table and I would prefer not modify the structure of it. |
| |||
| On 1 May, 10:36, skinhat <skin...@gmail.com> wrote: > In the following drupal table 'webform_submitted_data' the date > 12/8/2007 is specified via 3 records ie: > > 2 1176718828 0 12 > 2 1176718828 1 8 > 2 1176718828 2 2007 > > I need to be able to select a sid that value matches a certain date. > In the above example the sid value would be '2' if I wanted to select > with date '12/8/2007'. I was wondering if there was a mysql (4.1.21- > standard) SQL statement I could use select all the distinct sid values > that match a certain date. The following is an example of a > 'webform_submitted_data' table: > > sid cid no data > 2 1176015743 0 ali...@mailaby.com > 2 1176015500 0 alison > 2 1176015691 0 money > 2 1176718828 0 12 > 2 1176718828 1 18 > 2 1176718828 2 2007 > 2 1176851105 0 1 > 2 1176851105 1 8 > 2 1176851105 2 2008 > 2 1177590862 0 Cheapest flights please 7 adt 6 chd > 3 1176015743 0 ijwuishwe@mnqashiu > 3 1176015500 0 james > 3 1176015691 0 hogh > 3 1176718828 0 4 > 3 1176718828 1 5 > 3 1176718828 2 2008 > 3 1176851105 0 4 > 3 1176851105 1 26 > 3 1176851105 2 2008 > 3 1177590862 0 Cheapest easter seats please > 4 1176015743 0 jasnbuighe@kjnasiuh > 4 1176015500 0 david > 4 1176015691 0 wings > 4 1176718828 0 12 > 4 1176718828 1 8 > 4 1176718828 2 2007 > 4 1176851105 0 12 > > This is a drupal table and I would prefer not modify the structure of > it. SELECT DISTINCT `sid` WHERE LEFT(FROM_UNIXTIME(`cid`),10) = '2007-12-08'; |
| |||
| skinhat wrote: >> SELECT >> DISTINCT `sid` >> WHERE LEFT(FROM_UNIXTIME(`cid`),10) = '2007-12-08'; > > This wouldnt work because the 'cid' field doesnt hold the date. Its > just a unique identifier. > Yes, the cid column does hold the date, it's just in a unixtime format and the FROM_UNIXTIME() function would then convert it to a human readable format see the mysql documentation: http://dev.mysql.com/doc/refman/5.0/..._from-unixtime FROM_UNIXTIME(unix_timestamp), FROM_UNIXTIME(unix_timestamp,format) Returns a representation of the unix_timestamp argument as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone. unix_timestamp is an internal timestamp value such as is produced by the UNIX_TIMESTAMP() function. And then using the ten most left characters in the string would give you just the YYYY-MM-DD +------------------------------------+ | LEFT(FROM_UNIXTIME(1176015743),10) | +------------------------------------+ | 2007-04-08 | +------------------------------------+ -- //Aho |
| |||
| On May 1, 8:49 pm, "J.O. Aho" <u...@example.net> wrote: > skinhat wrote: > >> SELECT > >> DISTINCT `sid` > >> WHERE LEFT(FROM_UNIXTIME(`cid`),10) = '2007-12-08'; > > > This wouldnt work because the 'cid' field doesnt hold the date. Its > > just a unique identifier. > > Yes, the cid column does hold the date, it's just in a unixtime format and the > FROM_UNIXTIME() function would then convert it to a human readable format > Notice in the table these records: 2 1176718828 0 12 2 1176718828 1 18 2 1176718828 2 2007 3 1176718828 0 4 3 1176718828 1 5 3 1176718828 2 2008 Both have the same CID yet represent different dates. The first is 12/18/2007 and the second is 4/5/2008. |
| |||
| On 1 May, 12:03, skinhat <skin...@gmail.com> wrote: > On May 1, 8:49 pm, "J.O. Aho" <u...@example.net> wrote: > > > skinhat wrote: > > >> SELECT > > >> DISTINCT `sid` > > >> WHERE LEFT(FROM_UNIXTIME(`cid`),10) = '2007-12-08'; > > > > This wouldnt work because the 'cid' field doesnt hold the date. Its > > > just a unique identifier. > > > Yes, the cid column does hold the date, it's just in a unixtime format and the > > FROM_UNIXTIME() function would then convert it to a human readable format > > Notice in the table these records: > > 2 1176718828 0 12 > 2 1176718828 1 18 > 2 1176718828 2 2007 > > 3 1176718828 0 4 > 3 1176718828 1 5 > 3 1176718828 2 2008 > > Both have the same CID yet represent different dates. The first is > 12/18/2007 and the second is 4/5/2008. If they both have the same cid value than it is hardly a "unique" identifier! |
| |||
| On May 1, 9:06 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote: > On 1 May, 12:03, skinhat <skin...@gmail.com> wrote: > > > > > On May 1, 8:49 pm, "J.O. Aho" <u...@example.net> wrote: > > > > skinhat wrote: > > > >> SELECT > > > >> DISTINCT `sid` > > > >> WHERE LEFT(FROM_UNIXTIME(`cid`),10) = '2007-12-08'; > > > > > This wouldnt work because the 'cid' field doesnt hold the date. Its > > > > just a unique identifier. > > > > Yes, the cid column does hold the date, it's just in a unixtime format and the > > > FROM_UNIXTIME() function would then convert it to a human readable format > > > Notice in the table these records: > > > 2 1176718828 0 12 > > 2 1176718828 1 18 > > 2 1176718828 2 2007 > > > 3 1176718828 0 4 > > 3 1176718828 1 5 > > 3 1176718828 2 2008 > > > Both have the same CID yet represent different dates. The first is > > 12/18/2007 and the second is 4/5/2008. > > If they both have the same cid value than it is hardly a "unique" > identifier! The CID is unique to a certain date field. 1176718828 represents a date where no=0 is the day, no=1 month and no=2 is the year. A SID is equivalent to a record. This is the way drupal do it (www.drupal.org) for its webform module for dates. |
| |||
| On 1 May, 12:10, skinhat <skin...@gmail.com> wrote: > On May 1, 9:06 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote: > > > > > > > On 1 May, 12:03, skinhat <skin...@gmail.com> wrote: > > > > On May 1, 8:49 pm, "J.O. Aho" <u...@example.net> wrote: > > > > > skinhat wrote: > > > > >> SELECT > > > > >> DISTINCT `sid` > > > > >> WHERE LEFT(FROM_UNIXTIME(`cid`),10) = '2007-12-08'; > > > > > > This wouldnt work because the 'cid' field doesnt hold the date. Its > > > > > just a unique identifier. > > > > > Yes, the cid column does hold the date, it's just in a unixtime format and the > > > > FROM_UNIXTIME() function would then convert it to a human readable format > > > > Notice in the table these records: > > > > 2 1176718828 0 12 > > > 2 1176718828 1 18 > > > 2 1176718828 2 2007 > > > > 3 1176718828 0 4 > > > 3 1176718828 1 5 > > > 3 1176718828 2 2008 > > > > Both have the same CID yet represent different dates. The first is > > > 12/18/2007 and the second is 4/5/2008. > > > If they both have the same cid value than it is hardly a "unique" > > identifier! > > The CID is unique to a certain date field. 1176718828 represents a > date where no=0 is the day, no=1 month and no=2 is the year. A SID is > equivalent to a record. This is the way drupal do it (www.drupal.org) > for its webform module for dates.- Hide quoted text - > > - Show quoted text - No you are wrong. Unique means it is the only one of it's kind. This is not at all unique. It seems to be some sort of field identifier (that just happens to look like a unix timestamp. Date fields seem to be identified by a cid of either 1176718828 or 1176851105, whilst email addresses are identified by a cid of 1176015743, first names by 1176015500, last names by 1176015691, request info by 1177590862 and so on. It is my guess that the cid of 1176718828 represents one type of date (e.g. creation date) whilst 1176851105 may represent last update date (note that these cannot be the correct descriptions as all the dates are in the future. I will craft you a self join query that looks at the 1176718828 type dates, but you need to identify which of the dates it is that are relevant to you. |
| |||
| On May 1, 9:31 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote: > On 1 May, 12:10, skinhat <skin...@gmail.com> wrote: > > > > > On May 1, 9:06 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote: > > > > On 1 May, 12:03, skinhat <skin...@gmail.com> wrote: > > > > > On May 1, 8:49 pm, "J.O. Aho" <u...@example.net> wrote: > > > > > > skinhat wrote: > > > > > >> SELECT > > > > > >> DISTINCT `sid` > > > > > >> WHERE LEFT(FROM_UNIXTIME(`cid`),10) = '2007-12-08'; > > > > > > > This wouldnt work because the 'cid' field doesnt hold the date. Its > > > > > > just a unique identifier. > > > > > > Yes, the cid column does hold the date, it's just in a unixtime format and the > > > > > FROM_UNIXTIME() function would then convert it to a human readable format > > > > > Notice in the table these records: > > > > > 2 1176718828 0 12 > > > > 2 1176718828 1 18 > > > > 2 1176718828 2 2007 > > > > > 3 1176718828 0 4 > > > > 3 1176718828 1 5 > > > > 3 1176718828 2 2008 > > > > > Both have the same CID yet represent different dates. The first is > > > > 12/18/2007 and the second is 4/5/2008. > > > > If they both have the same cid value than it is hardly a "unique" > > > identifier! > > > The CID is unique to a certain date field. 1176718828 represents a > > date where no=0 is the day, no=1 month and no=2 is the year. A SID is > > equivalent to a record. This is the way drupal do it (www.drupal.org) > > for its webform module for dates.- Hide quoted text - > > > - Show quoted text - > > No you are wrong. Unique means it is the only one of it's kind. This > is not at all unique. It seems to be some sort of field identifier > (that just happens to look like a unix timestamp. Date fields seem to > be identified by a cid of either 1176718828 or 1176851105, whilst > email addresses are identified by a cid of 1176015743, first names by > 1176015500, last names by 1176015691, request info by 1177590862 and > so on. It is my guess that the cid of 1176718828 represents one type > of date (e.g. creation date) whilst 1176851105 may represent last > update date (note that these cannot be the correct descriptions as all > the dates are in the future. > > I will craft you a self join query that looks at the 1176718828 type > dates, but you need to identify which of the dates it is that are > relevant to you. Thanks. 1176851105 is the other date Im interested in but of course I can just replace 1176718828 with it. I consider myself good at SQL and spent quite a long time trying to get my head around it so if you can do it I'll be in awe at your skills |
| ||||
| On 1 May, 12:59, skinhat <skin...@gmail.com> wrote: > On May 1, 9:31 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote: > > > > > > > On 1 May, 12:10, skinhat <skin...@gmail.com> wrote: > > > > On May 1, 9:06 pm, Captain Paralytic <paul_laut...@yahoo.com> wrote: > > > > > On 1 May, 12:03, skinhat <skin...@gmail.com> wrote: > > > > > > On May 1, 8:49 pm, "J.O. Aho" <u...@example.net> wrote: > > > > > > > skinhat wrote: > > > > > > >> SELECT > > > > > > >> DISTINCT `sid` > > > > > > >> WHERE LEFT(FROM_UNIXTIME(`cid`),10) = '2007-12-08'; > > > > > > > > This wouldnt work because the 'cid' field doesnt hold the date. Its > > > > > > > just a unique identifier. > > > > > > > Yes, the cid column does hold the date, it's just in a unixtime format and the > > > > > > FROM_UNIXTIME() function would then convert it to a human readable format > > > > > > Notice in the table these records: > > > > > > 2 1176718828 0 12 > > > > > 2 1176718828 1 18 > > > > > 2 1176718828 2 2007 > > > > > > 3 1176718828 0 4 > > > > > 3 1176718828 1 5 > > > > > 3 1176718828 2 2008 > > > > > > Both have the same CID yet represent different dates. The first is > > > > > 12/18/2007 and the second is 4/5/2008. > > > > > If they both have the same cid value than it is hardly a "unique" > > > > identifier! > > > > The CID is unique to a certain date field. 1176718828 represents a > > > date where no=0 is the day, no=1 month and no=2 is the year. A SID is > > > equivalent to a record. This is the way drupal do it (www.drupal.org) > > > for its webform module for dates.- Hide quoted text - > > > > - Show quoted text - > > > No you are wrong. Unique means it is the only one of it's kind. This > > is not at all unique. It seems to be some sort of field identifier > > (that just happens to look like a unix timestamp. Date fields seem to > > be identified by a cid of either 1176718828 or 1176851105, whilst > > email addresses are identified by a cid of 1176015743, first names by > > 1176015500, last names by 1176015691, request info by 1177590862 and > > so on. It is my guess that the cid of 1176718828 represents one type > > of date (e.g. creation date) whilst 1176851105 may represent last > > update date (note that these cannot be the correct descriptions as all > > the dates are in the future. > > > I will craft you a self join query that looks at the 1176718828 type > > dates, but you need to identify which of the dates it is that are > > relevant to you. > > Thanks. 1176851105 is the other date Im interested in but of course I > can just replace 1176718828 with it. > > I consider myself good at SQL and spent quite a long time trying to > get my head around it so if you can do it I'll be in awe at your > skills > > - Show quoted text - Shucks! Fancy being in awe of little-ole me! SELECT DISTINCT `w1`.`sid` FROM `webf` `w1` JOIN `webf` `w2` ON `w2`.`cid` = '1176718828' AND `w1`.`sid` = `w2`.`sid` AND `w2`.`no` = '2' JOIN `webf` `w3` ON `w3`.`cid` = '1176718828' AND `w1`.`sid` = `w3`.`sid` AND `w3`.`no` = '0' JOIN `webf` `w4` ON `w4`.`cid` = '1176718828' AND `w1`.`sid` = `w4`.`sid` AND `w4`.`no` = '1' WHERE `w2`.`data` = '2007' AND `w3`.`data` = '12' AND `w4`.`data` = '8' |