Jump to content

Recommended Posts

Hello,

 

I have a directory, that is pulling from 2 tables, a simple directory 'table', and a more complex 'store' table.

 

Right now, you can either choose to look at 1 table or the other. This is working fine.

 

I would like the user to be able to just see a master list of both mixed into one list.

 

I'm not sure if i can use join as i'm not trying to link up values from both tables, i would just like to grab all the info from both, sort by name and display to the user.

 

Sorry if this is confusing, but does anyone have any ideas?

 

Thanks,

 

envex

Link to comment
https://forums.phpfreaks.com/topic/131805-a-little-fuzzy-on-join/
Share on other sites

After reading the gudilines post, i have additional info:

 

CREATE TABLE `store` (
`id` int(100) NOT NULL auto_increment,
`contact_name` varchar(250) NOT NULL,
`username` varchar(200) NOT NULL,
`name` varchar(500) NOT NULL,
`email` varchar(500) NOT NULL,
`password` varchar(40) NOT NULL,
`slug` varchar(100) NOT NULL,
`mem_type` int(1) NOT NULL,
`pic` varchar(500) NOT NULL,
`paid` varchar(1) NOT NULL default '0',
`recur_date` date NOT NULL,
`recur_type` int(1) NOT NULL,
`description` text,
`website` varchar(250) default NULL,
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=20 DEFAULT CHARSET=utf8

 

CREATE TABLE `directory_item` (
`id` int(100) NOT NULL auto_increment,
`name` varchar(250) NOT NULL,
`contact` varchar(300) NOT NULL,
`email` varchar(300) NOT NULL,
`website` varchar(200) default NULL,
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=388 DEFAULT CHARSET=utf8

 

mysql_query = SELECT * FROM `directory_item` UNION SELECT * FROM `store`

  GROUP BY `name`

  LIMIT 0,15'

You can but you need to select "dummy" data from the other table to preserve the number of columns

SELECT id, name, contact_name as contact, email, website, slug, recur_type
FROM store
UNION
SELECT id, name, contact, email, website, '', 0
FROM directory
ORDER BY name 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.