Nothing is being returned when I execute this query!
I'm trying to have multiple values for same column
n
please, can you help?
答案 0 :(得分:2)
Change the 'AND' to an 'OR'. A number (or anything else in a table column for that matter) cannot be both values at the same time
qt 5.10
Where you need rows where an element can be one of a number of values, it is common to use IN instead of repeated OR clauses, as this makes the expression clearer:
$ brew list --versions qt5
qt 5.10.1
As one of your Number values has a leading zero, I presume it is genuinely a string. You might want to name your columns better.
答案 1 :(得分:1)
Or better use the void writeing(FILE* dat, int user_number, USER* user) {
int i = user_number- 1;
printf("Name: ");
scanf("%s", (user + i)->name);
printf("Last name: ");
scanf("%s", (user + i)->last_name);
printf("ID number: ");
scanf("%d", &(user + i)->id_number);
printf("Phone: ");
scanf("%d", &(user + i)->phone);
fwrite(user, sizeof(*user), 1, dat);
}
void reading(FILE* dat, int user_number, USER* user)
{
fread(user, sizeof(USER), user_number, dat);
for (int i = 0; i < user_number; i++)
{
fprintf(stdout, "Name: %s\nLast name: %s\nID number: %d\nPhone: 0%d\n", (user + i)->name, (user + i)->last_name, (user + i)->id_number, (user + i)->phone);
}
}
operator, so you could filter for even more values:
SELECT * FROM users WHERE number IN(1212, 0921, 1452, 1265);
答案 2 :(得分:0)
Try this:
SELECT * FROM users where Number=1212 OR Number=0921
答案 3 :(得分:0)
Change AND by OR, if you need to check equality with more values you could just use int main() {
int n = 0, user_number = 0;
USER *user = NULL;
user = (USER*)calloc(100, sizeof(USER));
FILE *dat = NULL;
while (n != 4) {
printf("Press 1 for creating binary file! \n");
printf("Press 2 for reading! \n");
printf("Press 3 to enter new user! \n");
printf("Press 4 to exit!\n\n");
printf("Number: ");
scanf("%d", &n);
printf("\n");
switch (n)
{
case 1:
dat = fopen("User.bin", "wb");
printf("File created.\n");
fclose(dat);
break;
case 2:
dat = fopen("User.bin", "rb");
reading(dat, user_number, user);
printf("\n");
fclose(dat);
break;
case 3:
user_number++;
printf("Insert details of %d user: \n", user_number);
dat = fopen("User.bin", "ab");
writeing(dat, user_number, user);
printf("\n");
fclose(dat);
break;
case 4:
printf("Program closed!\n");
break;
default:
break;
}
}
free(user);
system("PAUSE");
return 0;
}