On Mon, 19 Jan 2009, Duane Hill wrote:

I have two tables defined:

   CREATE TABLE `tga_body` (
     `body_id` int(10) unsigned NOT NULL auto_increment,
     `blob_pos` mediumint(8) unsigned NOT NULL,
     `file_id` int(10) unsigned NOT NULL,
     `blob_id` int(10) unsigned NOT NULL,
     PRIMARY KEY  USING BTREE (`body_id`),
     KEY `file_id` (`file_id`),
     KEY `blob_id` (`blob_id`)
   ) ENGINE=MyISAM;

   CREATE TABLE `tga_body_blob` (
     `blob_id` int(10) unsigned NOT NULL auto_increment,
     `blob_data` mediumblob NOT NULL,
     PRIMARY KEY  USING BTREE (`blob_id`),
     KEY `blob_data` (`blob_data`(64))
   ) ENGINE=MyISAM;

I need to select all tga_body_blob.blob_data where tga_body.blob_id is equal to tga_body_blob.blob_id and tga_body.file_id is equal to 'some_name' ordered by tga_body.blob_pos.

I can type in english what I want. However, I am stumped on the select statement. I'm speculating I will need to use some form of JOIN but am unsure.

I don't know if this is an accurate way of solving or not. I managed to get what I wanted by this select statement:

    SELECT * FROM tga_body,tga_body_blob
        WHERE tga_body.file_id = some_id
            AND tga_body.blob_id = tga_body_blob.blob_id
        ORDER BY tga_body.blob_pos

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to