Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-16-2004, 11:55 PM   #1 (permalink)
infinite_root
Registered User
 
infinite_root's Avatar
 
Join Date: Apr 2004
Posts: 26
infinite_root is on a distinguished road
Help on MySQL Statements

Hi I had a problem, hope you can help me.

Here's my database info:

Database name: sms
Table1: Visa
Field: Visa (there are many types of visa entry such as V001, V002, etc.)

Table2: Vessel
Field1: VictorVsl
Field2: Onboard

Here's what I would like to do:

I would like my query to provide search results of "all personnel" with or without "visa", which were "onboard" on a vessel named "VictorVsl" to be listed on the list.

HOw can I do that?

I am using MySQL 4.0.20-1.

Thanks and more power.
infinite_root is offline   Reply With Quote
Old 08-17-2004, 05:07 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,446
sde is on a distinguished road
i don't understand what field your table/field your personell is in.

could you describe your database a little better? if it is field 1 and field2, then maybe:
Code:
select distinct Field2 from Vessel where Field1='VictorVsl';
that will work if field 2 is the names of peronnel, .. but i'm not sure i understand your db structure.
__________________
Mike
sde is online now   Reply With Quote
Old 08-18-2004, 05:59 AM   #3 (permalink)
veedee
Registered User
 
Join Date: Jul 2004
Posts: 4
veedee is on a distinguished road
Is there any correlationship beeween table1 and table2 ?
___________________
free ebook | free ebook download
veedee is offline   Reply With Quote
Old 04-20-2005, 02:56 PM   #4 (permalink)
Dagger-ACS
Registered User
 
Join Date: Apr 2005
Posts: 1
Dagger-ACS is on a distinguished road
MYSQL Statement Help...

I need help with the correct syntax::
Here is the db Structure:

Table Visitor
Visitor_ID <PK>
FirstName
LastName

Table Attendance
Attendance_ID
Visitor_ID <FK>
Date

I need to know the correct Select statement to return DISTINCT(CONCAT(FirstName, ',' LastName)) AS Name

Where it would return rows from the visitor table where they had no row in the attendance table for a given date. In other words I want to list any visitor who was not there on a specific date. I hope this is clear enough for you guys. My communication skillz are poor...

TIA

Dag
Dagger-ACS is offline   Reply With Quote
Old 04-21-2005, 12:19 PM   #5 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 596
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Code:
SELECT Visitor.FirstName Visitor.LastName FROM Visitor, Attendance WHERE Visitor.ID = Attendance.Visitor_ID AND Attendance.Date = 2004-10-12;
Would get all the visitors who DID attend on a given date. I'm not sure if you can negate that.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 04-21-2005, 05:37 PM   #6 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
technobard is on a distinguished road
Well, you might try this approach:

First, find all of the distinct visitor_id values that did attend on a given date.
select distinct visitor_id from attendance
where date = '2004-10-12'


Then select what you want from the VISITOR table where the visitor_id is not in the first list.
select distinct .... from visitor
where visitor_id not in (select distinct visitor_id from attendance
where date = '2004-10-12')
__________________
It takes 2 points to draw a straight line, but at least 3 points to draw a conclusion.
technobard is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Views sde PHP 1 05-01-2003 12:06 PM
and on to mysql .. sde Linux / BSD / OS X 2 01-18-2003 07:39 PM
mySQL Ilya020 PHP 8 01-18-2003 06:23 PM


All times are GMT -8. The time now is 09:13 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting