Write a my sql query to select all username who had nokia purchased handsets "N72" in the year 2008.
tables given below:
Thanks -
-- 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');
-
-
2 2232
First the tables: - -- Table structure for table `users`
-
--
-
-
CREATE TABLE `users` (
-
`user_id` int(11) NOT NULL auto_increment,
-
`username` varchar(30) NOT NULL,
-
PRIMARY KEY (`user_id`)
-
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;
-
-
-
-- Table structure for table `handsets`
-
--
-
-
CREATE TABLE `handsets` (
-
`handsets_id` int(11) NOT NULL auto_increment,
-
`user_id` int(11) NOT NULL,
-
`handsets` varchar(20) NOT NULL,
-
`purchase_date` date NOT NULL,
-
PRIMARY KEY (`handsets_id`)
-
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
Second the query: - SELECT username FROM users ,handsets
-
WHERE users.user_id=handsets.user_id
-
and handsets='n72'
-
and purchase_date between '2008-01-01' and '2008-12-31'
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tanamon |
last post by:
Hello All,
I am a MySQL newbie trying to write a query that selects file_name records
possessing the highest numbered version for that unique file_name. I show
sample data and two trial queries...
|
by: Himmel |
last post by:
Hello!
The reference database I currently use runs queries that pull data from hundreds of tables in order to create user-friendly form view. The problem is that these queries can take upwards of...
|
by: matias.cornejo |
last post by:
I have a table with 1.000.000 registers and I want to find the
register in a position 25.000. I don't want to use a cursor, how can I
do it in other way?
Thenks in advance
|
by: sara |
last post by:
Hi -
I have a table keeping track of employees' jobs in a location. So,
Store #1 Manager #353, AsstMgr #556
Store #2 Manager #776, AsstMgr #132
etc.
The table is
Date StoreNum MgrNum ...
|
by: harik82 |
last post by:
Hi All,
In one of my UDF i have writen the query as shown below, but it is throwing sme errors. Can any one help me to solve this problem.....very urgent....
IF ((select...
|
by: viki1967 |
last post by:
Hi.
I have a table in a mysql db:
NAME ROLE DATE TYPE
MARK STR 2008-04-28 B
KARL MAN ...
|
by: gagandeepsngh |
last post by:
'Code for selecting a particular data from database
'***** START *****
sSQL = "SELECT name FROM trans"
cmd = New OleDbCommand(sSQL, con)
Dim reader As OleDbDataReader = cmd.ExecuteReader()...
|
by: micropos |
last post by:
hi everyone,who can help me solve the problem?this is my code:
<?php
include 'C:/wamp/www/micropos/condb1.php';
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could...
|
by: Octo Siburian |
last post by:
How do I interpret the declaration time 'AM' and 'PM' in Ms.access Query
I have Query Select in vb6.0
to get data from Ms.access database
SQLSelectdbRAS = "SELECT a.DN, b.DIN, c.PIN,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |