SQL PrimaryKey

  • Thread starter Thread starter Anna Kubiak
  • Start date Start date
A

Anna Kubiak

Hi,

I have primary key consisting of 2 fields. how to write SQL Statement to
find 1 record. I tried


Select * FROM table where PrimaryKey.field1+Primary.Field2=const1+const2;

Doesn't work :-(

Anna
 
Try this:

Select * FROM table where (PrimaryKey.field1=const1) And (Primary.
Field2=const2);

By the way, if your two constants are coming from a form they need to be
identified as: Forms!MyFormName!const1, for example. If the user is going to
enter them at run time, they should say PrimaryKey.field1=[enter const1], for
example, with the data entry requirement in brackets.

Unless I know more about your query's source info, I'm only guessing as to
what you really need to do.

Sam
 
Don't use the + sign to join fields together. Access will add the data if
both fields are a number.

Also in your example you are using PrimaryKey.field1 & Primary.Field2. If
anything it should be table.field1 & table.Field2

Instead try:

Select *
From table
Where table.field1 & table.Field2 = const1 & const2;

Better yet:
Select *
From table
Where table.field1 = const1
And table.Field2 = const2;
 
U¿ytkownik "OfficeDev18 via AccessMonster.com said:
Try this:

Select * FROM table where (PrimaryKey.field1=const1) And (Primary.
Field2=const2);
Sorry, I've tried, doesn't work too. I had Message in Polish - something
like that - may be not unique PrimaryKey.Field1

:-(
 
Back
Top