Query to check a field and select fields from a table

R

Rodrigo Borges

I have 2 tables (tServers and tTimezone) with the following structure:

tServers:
servername
city

tTimezone:
city
time1
time2

My query need to check if [tServers].servername is like "*DOWD*" and
return a field "time" populating with [tTimezone].time2. I joined both
tables using city.
 
C

Carl Rapson

Rodrigo Borges said:
I have 2 tables (tServers and tTimezone) with the following structure:

tServers:
servername
city

tTimezone:
city
time1
time2

My query need to check if [tServers].servername is like "*DOWD*" and
return a field "time" populating with [tTimezone].time2. I joined both
tables using city.

SELECT tTimezone.time2
FROM tServers INNER JOIN tTimezone ON tServers.city=tTimezone.city
WHERE tServers.servername LIKE "*DOWD*";

Carl Rapson
 
R

Rodrigo Borges

I do need to use a condicional because I have more than 1 information to
check...

exampe: if servername like "*dowd*" = time2, if servername like *dowb* =
time1....

Tks for your reply Carl and soory for do not provide these information
before...

Carl Rapson said:
Rodrigo Borges said:
I have 2 tables (tServers and tTimezone) with the following structure:

tServers:
servername
city

tTimezone:
city
time1
time2

My query need to check if [tServers].servername is like "*DOWD*" and
return a field "time" populating with [tTimezone].time2. I joined both
tables using city.

SELECT tTimezone.time2
FROM tServers INNER JOIN tTimezone ON tServers.city=tTimezone.city
WHERE tServers.servername LIKE "*DOWD*";

Carl Rapson
 
C

Carl Rapson

I don't think that can be done in a query, because you can't conditionally
specify the fields to be selected. It would be fairly simple in VBA code.

Carl Rapson

Rodrigo Borges said:
I do need to use a condicional because I have more than 1 information to
check...

exampe: if servername like "*dowd*" = time2, if servername like *dowb* =
time1....

Tks for your reply Carl and soory for do not provide these information
before...

Carl Rapson said:
Rodrigo Borges said:
I have 2 tables (tServers and tTimezone) with the following structure:

tServers:
servername
city

tTimezone:
city
time1
time2

My query need to check if [tServers].servername is like "*DOWD*" and
return a field "time" populating with [tTimezone].time2. I joined both
tables using city.

SELECT tTimezone.time2
FROM tServers INNER JOIN tTimezone ON tServers.city=tTimezone.city
WHERE tServers.servername LIKE "*DOWD*";

Carl Rapson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top