View Single Post

   
  #9 (permalink)  
Old 02-28-2008, 09:43 AM
skinhat
 
Posts: n/a
Default Re: SQL statement to select from a drupal webform table

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 .

Reply With Quote