0

Hi I need some help with this..

I have tables in sql with the following values;

Tbl name - members
memberid - primary key
Username
Password

Tbl name -Orders

Orderid -primary key
memberid - foreign key
orderno


I want to be able to grab the order numbers by the specific member.

I have two members in the sql database.
I have two orders in the sql database.


Here is my sql i used to create the tables -
members -

CREATE TABLE `members` (
  `memberid` int(4) NOT NULL auto_increment,
  `Username` varchar(65) collate latin1_general_ci NOT NULL,
  `Password` varchar(65) collate latin1_general_ci NOT NULL,
  PRIMARY KEY  (`memberid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1002 ;

--
-- Dumping data for table `members`
--

INSERT INTO `members` VALUES(1000, 'qprping', '1234');
INSERT INTO `members` VALUES(1001, 'xrated', 'password');

orders-

CREATE TABLE `Orders` (
  `Orderid` int(11) NOT NULL,
  `Orderno` int(11) NOT NULL,
  `memberid` int(11) default NULL,
  PRIMARY KEY  (`Orderid`),
  KEY `memberid` (`memberid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

--
-- Dumping data for table `Orders`
--

INSERT INTO `Orders` VALUES(1010, 5892584, 1000);
INSERT INTO `Orders` VALUES(1011, 1234567, 1001);

How do I do this using php?

2
Contributors
5
Replies
8
Views
6 Years
Discussion Span
Last Post by Stefano Mtangoo
0

I have not understood your question but I think you might need to check table joining, especially inner join. May be explaining what you want to accomplish might help!

0

If you look in the members sql the memberid is related to a specific order in the orders table

so I want to get that specific order number by the member id

Edited by ben.matthews18: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.