Mysql join columns from multiple tables -


i have 1 main table , 2 tables hold multiple dinamyc information first table.

the first table called 'items' holds main information. there 2 tables (ratings , indexes) holds information values dinamyc count of auditories , time period.

what want: when query items, want result have additional column names ratings , indexes tables.

i have code this

select items.*, ratings.val rating, indexes.val idx items,ratings,indexes  items.date>=1349902800000 , items.date <=1349989199000  , ratings.period_start <= items.date  , ratings.period_end > items.date  , ratings.auditory = 'kids' , indexes.period_start <= items.date  , indexes.period_end > items.date  , indexes.auditory = 'kids' order indexes.added, ratings.added desc 

the tables this

items:

`id` int(11) not null auto_increment, `name` varchar(200) default null, `date` bigint(40) default null primary key (`id`) 

ratings:

`id` bigint(50) not null auto_increment, `period_start` bigint(50) default null, `period_end` bigint(50) default null, `val` float default null, `auditory` varchar(200) default null, `added` timestamp null default current_timestamp, primary key (`id`) 

all dates except 'added' fields simple timestamps bigint format - miliseconds whatever date in as3 when date.gettime();

so - correct way acomplished?

the thing i'm not seeing unique correlation of individual item ratings... think ratings table need "itemid" link items. stands now, if have 100 items within given time period 3 months... , add ratings / reviews, don't associate ratings actual item, stuck. put itemid in , add condition , should go.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -