multiple-tables

How can I find a max/min date using multiple tables in sql 2005

I'm rather new to coding so I'm sure this is fairly easy, but I have not been able to figure this out. I'm building a report in reporting serivces, sql 2005. I have 4 tables: people, event log, program enrollment and program info. I have clients that could be enrolled in numerous programs. I need to be able to find a client's first enrol...

Doctrine: Unable to execute either CROSS JOIN or SELECT FROM Table1, Table2?

Using Doctrine I'm trying to execute either a 1. CROSS JOIN statement or 2. a SELECT FROM Table1, Table2 statement. Both seem to fail. The CROSS JOIN does execute, however the results are just wrong comparing to execution in Navicat. The multiple table SELECT doesn't even execute because Doctrine automatically tries to LEFT JOIN the ...

how to diffrentiate between same field names of two tables in a select query??

i have more than two tables in my database and all of them contains same field names like table A table B table C field1 field1 field1 field2 field2 field2 field3 field3 field3 . . . . . . . . ...

Mysql - Help me alter this search query involving multiple joins and conditions to get the desired results

About the system: We are following tags based search. Tutors create packs - tag relations for tutors stored in tutors_tag_relations and those for packs stored in learning_packs_tag_relations. All tags are stored in tags table. The system has 6 tables - tutors, Users (linked to tutor_details), learning_packs, learning_packs_tag_relatio...

Cakephp Auth with multiple "Users" tables

Hi, I would like to know how to deal with only ONE authentification process and "users" in multiple tables. I have 4 Users table: users, admins, artists, teamadmins which all have specific fields, but I would like all of these users to be able to connect via only one form on the homepage, and being redirected after that to their specific...

Mysql - help me optimize this query

About the system: -The system has a total of 8 tables - Users - Tutor_Details (Tutors are a type of User,Tutor_Details table is linked to Users) - learning_packs, (stores packs created by tutors) - learning_packs_tag_relations, (holds tag relations meant for search) - tutors_tag_relations and tags and orders (containing purchase det...

Mysql - help me optimize this query (improved question)

About the system: - There are tutors who create classes and packs - A tags based search approach is being followed.Tag relations are created when new tutors register and when tutors create packs (this makes tutors and packs searcheable). For details please check the section How tags work in this system? below. Following is the concerned...

Mysql - Help me change this single complex query to use temporary tables

About the system: - There are tutors who create classes and packs - A tags based search approach is being followed.Tag relations are created when new tutors register and when tutors create packs (this makes tutors and packs searcheable). For details please check the section How tags work in this system? below. Following is the concerned...

DQL delete from multiple tables (doctrine)

Need to perform DQL delete from multple related tables. In SQL it is something like this: DELETE r1,r2 FROM ComRealty_objects r1, com_realty_objects_phones r2 WHERE r1.id IN (10,20) AND r2.id_object IN (10,20) I need to perform this statement using DQL, but I'm stuck on this :( <?php $dql = Doctrine_Query::create() ->del...

Database Design - How do I setup an FK relationship to 1 of 2 tables??

What is the best way to maintain a unique ID field across multiple database tables? My database contains both businesses and people, and both entities need to have a unique ID field associated with it. In addition, there are other tables (for example Addresses) which can reference either a business or a person using their ID as a foreig...

Auto increment over multiple identity columns in MS SQL 2005 or 2008

Hi, I want to have two different tables in MS SQL, for example users and groups, both with identity column. It is possible to create auto increment over two identity columns? I want to have third table with common informations to these two tables and I want to identify unique record. In Oracle is SEQUENCE. It is possible to do it? Tha...

Most efficient way to do a conditional mysql join on multiple tables? (Yii php framework)

I have five tables: tab_template template_group group user_group user Tab_template's are organized into groups with the template_group relational table. Users's are organized into groups with the user_group relational table. Group's can be public or private (using a tinyint boolean column in the table). I want to query for all of th...

mysql pagination with multiple tables

I have 2 two tables: organisations (id, name) organisationsmeta (id, orgId, metaKey, metaValue) Each organisation can have multiple associated meta rows. I'm using a Left Join right now since there can be organisations without any meta data. How do I construct the query to fetch 10 organisations (with all associated meta data), regard...

Highly filtered search based on multiple conditions

I have two tables in a restaurant search done in php. All the information about the restaurant type, facilities, cuisines are in entered to Table2 -'stack' with reference to their restuarant id in the table 1. How do i run a query so that i can get all the restaurant that serve chineese and also serves dinner and also have parking? This...

MySQL Keyword Search Across Multiple Tables

I have three tables in a MySQL database used in a music library application: The Genre table has columns: id title (string) The Album table has columns: id genre_id (foreign key to Genre.id) title (string) artist (string) and the Track table has columns: id album_id (foreign key to Album.id) title (string) Each Album can hav...

Listing data from mysql tables

Hi. I have 3 tables: recipe_category cid | category 1 | desserts 2 | cakes 3 | biscuits recipe_name id | recipe_name | cid | iid 1 | black forest cake | 1,2 | 1,2,3,4 2 | angel cake | 2 | 1,2,4 3 | melting moments | 3 | 2,5 4 | croquembouche | 1,3 | 1,5 ingredients iid | ingredient_name 1 | self...

How to do Outer Join on >2 Tables (Oracle)

I'm not sure how to describe my table structure, so hope this makes sense... I have 3 tables in hierarchical relationship such that A has a one to many relationship to B which in turn has a one to many relationship with C. The trick is that the foreign key in B and C are allowed to be null (i.e. no parent defined). I also have D and E...

Left Joining on Multiple Tables with Timestamps

Ok SQL and Oracle gurus I have a somewhat complicated query that I'm trying to build. Here is my current query: select distinct person_info.person_name table2.value, table3.value, table4.value, table5.value from person_info left join table2 on table2.person_name=person_info.person_name left join table3 on ta...

sql - insert into multiple tables in one query

assuming that i have two tables, names and phones and i want to insert data from some input to the tables, in one query- How can it be done? Please, if it can be done, explain the syntax. ...

PHP data taken from one MySQL table, displayed to user and than new data plus this data being written to new table

OK that probably sounded a bit confusing but what I have is a table that spits out courses locations and dates depending on what the user chooses. I than want the user to go through the fields and than on the 3rd submit button I have the course information displayed to them. I'm asking how in php i can take the echo from the first query...