Write a my sql query to select all username who had nokia purchased handsets "N72" in the year 2008.
tables given below:
Thanks
tables given below:
Thanks
Code:
-- phpMyAdmin SQL Dump -- version 3.2.0.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Nov 02, 2010 at 10:51 AM -- Server version: 5.1.37 -- PHP Version: 5.3.0 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `intTest` -- -- -------------------------------------------------------- -- -- Table structure for table `handsets` -- CREATE TABLE IF NOT EXISTS `handsets` ( `handsets_id` varchar(10) NOT NULL, `user_id` varchar(10) NOT NULL, `handsets` varchar(20) NOT NULL, `purchase_date` varchar(20) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `handsets` -- INSERT INTO `handsets` (`handsets_id`, `user_id`, `handsets`, `purchase_date`) VALUES ('1', '1', 'n72', '2008-03-19'), ('2', '1', '1610', '2009-03-19'), ('3', '1', '3210', '2009-03-19'), ('4', '2', 'n72', '2008-03-19'), ('5', '3', '6680', '2009-03-19'), ('6', '3', '6681', '2009-03-19'), ('7', '3', 'n72', '2009-03-19'); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE IF NOT EXISTS `users` ( `user_id` varchar(10) NOT NULL, `username` varchar(30) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `users` -- INSERT INTO `users` (`user_id`, `username`) VALUES ('1', 'nipun'), ('2', 'rohit'), ('3', 'sumit');
Comment