| |

VerySource

 Forgot password?
 Register
Search
View: 860|Reply: 8

Help solve a SQL statement problem

[Copy link]

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-1 13:20:01
| Show all posts |Read mode
Help solve a SQL statement problem: The table name is fixed (student), the field name is uncertain (name, class, Id ...), and the data of the field is not fixed. Now I want to find the data by a query. Use the variable condition to indicate the field name value How should I write a SQL statement like the query condition of the selected field?
Reply

Use magic Report

0

Threads

64

Posts

45.00

Credits

Newbie

Rank: 1

Credits
45.00

 China

Post time: 2020-3-13 18:45:01
| Show all posts
Configure with strings
Reply

Use magic Report

0

Threads

43

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-3-15 00:00:01
| Show all posts
sql = "select" + condition + "from student where" + value
Reply

Use magic Report

0

Threads

43

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-3-15 07:30:01
| Show all posts
sql = "select"&condition&"from student where"&value
Reply

Use magic Report

1

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-3-16 16:30:01
| Show all posts
sql = "SELECT" + condition + "FROM STUDENT WHERE" + VALUE
Pay attention to spaces
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-17 17:00:01
| Show all posts
select *
from
student
where condition = 'value'
go
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-3-18 09:30:01
| Show all posts
Thank you, the problem is solved
Reply

Use magic Report

1

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-3-18 11:00:01
| Show all posts
The problem is solved
Reply

Use magic Report

0

Threads

5

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-18 14:15:01
| Show all posts
Use variables to join.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list