Wrox Programmer Forums
|
Other Programming Languages If you have a coding issue to discuss about another language that really isn't provided for in any other forum here (not ASP.NET C#, C++, VB, PHP, JavaScript, Python, Java, Perl, Applescript, XML or any of the other forum topics we have), post it here. Enough discussion on a language we don't have covered could prompt a new forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Other Programming Languages section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 7th, 2006, 01:14 AM
Registered User
 
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to purnendu2311 Send a message via AIM to purnendu2311 Send a message via MSN to purnendu2311 Send a message via Yahoo to purnendu2311
Default query problem

Hello all,

I am tring to execute this condition based query from two table(product & itemdetails),
 where,
 if prod_type from itemdetails is "exclusive"
then
prod_status from product table is inactive
else
prod_status from product table is active.
then

This is my table structure:::::::::::::::

CREATE TABLE `itemdetails` (
  `sno` int(11) NOT NULL auto_increment,
  `cart_id` varchar(60) default NULL,
  `prod_id` varchar(30) default NULL,
  `prod_price` double(5,0) default NULL,
  `prod_desc` varchar(250) default NULL,
  `prod_quantity` int(2) default NULL,
  `prod_type` varchar(20) default NULL,
  `prod_source` varchar(30) default NULL,
  `prod_colour` varchar(30) NOT NULL default '',
  `prod_colno` int(10) NOT NULL default '0',
  PRIMARY KEY (`sno`)
) ENGINE=MyISAM AUTO_INCREMENT=139 DEFAULT CHARSET=latin1;

/*Data for the table `itemdetails` */

insert into `itemdetails` values

(82,'ef253b43f5cbd61142e71b90de6cc327','INF001',45 00,'test',1,'Non-exclusive','.psd,.html','INF001BL',1),

(81,'ef253b43f5cbd61142e71b90de6cc327','HOL001',60 00,'description',1,'Non-exclusive','.psd,.html','HOL001RL',3),

(80,'ef253b43f5cbd61142e71b90de6cc327','BUS001',50 0,'nothing ',1,'Non-exclusive','.psd,.html','BUS001BL',1),

(61,'6bdf65b5714a7bf7f997f51c52d92805','BUS001',10 00,'nothing ',1,'Exclusive','.psd,.html','BUS001GL',2),

(62,'6bdf65b5714a7bf7f997f51c52d92805','BUS003',12 000,'test',1,'Exclusive','.psd,.html','BUS003BL',1 );




CREATE TABLE `product` (
  `sno` int(11) NOT NULL auto_increment,
  `prod_id` varchar(20) NOT NULL default '',
  `prod_desc` text NOT NULL,
  `prod_nonexclusive` double(5,0) default NULL,
  `prod_exclusive` double(5,0) NOT NULL default '0',
  `prod_colour` varchar(50) NOT NULL default '',
  `prod_source` varchar(50) NOT NULL default '',
  `prod_date` date NOT NULL default '0000-00-00',
  `image1_small` longblob,
  `image1_big` longblob,
  `image1_small_type` varchar(20) default NULL,
  `image1_big_type` varchar(20) default NULL,
  `image1_prod_id` varchar(20) NOT NULL default '',
  `image2_small` longblob,
  `image2_big` longblob,
  `image2_small_type` varchar(20) default NULL,
  `image2_big_type` varchar(20) default NULL,
  `image2_prod_id` varchar(20) NOT NULL default '',
  `image3_small` longblob,
  `image3_big` longblob,
  `image3_small_type` varchar(20) default NULL,
  `image3_big_type` varchar(20) default NULL,
  `image3_prod_id` varchar(20) NOT NULL default '',
  `image4_small` longblob,
  `image4_big` longblob,
  `image4_small_type` varchar(20) default NULL,
  `image4_big_type` varchar(20) default NULL,
  `image4_prod_id` varchar(20) NOT NULL default '',
  `prod_status` varchar(20) default NULL,
  PRIMARY KEY (`sno`,`prod_id`),
  UNIQUE KEY `sno` (`sno`),
  KEY `prod_colour` (`prod_colour`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Plz help me, urgent.

Regards
puru



shopping
Reply With Quote
  #2 (permalink)  
Old December 1st, 2006, 02:51 PM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

First things first.

I dont notice in your table structures that you have and foriegn key restrictions on the sno column stating that they must resemble one another. Could be wrong as Im used to postgreSQL and not mySQL.

After you have that setup, maybe you already do. You just need a join the tables to query from both.

select i.snow,i.product_status from itemdetails as i,products as p where i.sno=p.snow and .

Then your returned 2 columns, the primary key/id and the string your looking for.

Reply With Quote
  #3 (permalink)  
Old December 1st, 2006, 02:53 PM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by jlh42581
 First things first.

I dont notice in your table structures that you have and foriegn key restrictions on the sno column stating that they must resemble one another. Could be wrong as Im used to postgreSQL and not mySQL.

After you have that setup, maybe you already do. You just need a join the tables to query from both.

select i.snow,i.product_status from itemdetails as i,products as p where i.sno=p.sno;

Then your returned 2 columns, the primary key/id and the string your looking for.

In your sql loop, create an if

if(return[1] == "inactive){
  do somthing
}
else{
  do somthing else
}

Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Query Problem. rupen Access 3 April 27th, 2007 07:43 AM
Query Problem bundersuk VB Databases Basics 0 December 30th, 2006 07:50 AM
problem with query harpua Classic ASP Databases 1 January 24th, 2005 12:36 PM
Problem in query leo_vinay Classic ASP Databases 5 January 21st, 2005 06:32 AM
query problem mateenmohd SQL Server 2000 7 September 9th, 2003 11:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.