Ankit Pai

Greenhorn
+ Follow
since Dec 01, 2018
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ankit Pai

Well Sir, the thing is im trying to understand how
2 weeks ago
What would I have to do, in order to do this ?

Then, if the name and/or City textfields have data in them, add SQL text to your query string. For example, in the second screen above, the final query string would be:
2 weeks ago
Could you give me an example of a prepared statement?
2 weeks ago
Now, how would I add that string to the Query Statement?
2 weeks ago
I was planning on making methods, but I'm trying to figure out how to get data from textfield and radiobuttons and add the string to the query statement
2 weeks ago


This is the database, I also used JavaFx to make a GUI, I used two textfields and a group of three radiobuttons in a togglegroup

2 weeks ago
Queries

You will have to build a dynamic query statement. My advice would be to start with a basic query string: "select * from customers ". Then, if the name and/or City textfields have data in them, add SQL text to your query string. For example, in the second screen above, the final query string would be:

select * from customers where city like 'Tampa%' order by zip

If the user entered 'Forth' for the name, and 'T' for the city, then the query would look like:

select * from customers where name like 'Forth%' and city like 'T%' order by name

Note that I'm using 'like' in the where clause. This means that the query will look for names starting with 'Forth', and cities starting with 'T' -- Tampa in our db.

Also remember to include the logical AND if both name and city textfields are selected. Otherwise, the where clause does not include any logical operator.

Once you have your query string built, you can then execute it. (a executeQuery statement is fine). Loop through the result set and build a nice formatted string for each result, which you will then append to the text area using the appendText() method.

https://gyazo.com/595e7759ac930befc21f871a69f8f6c8

https://gyazo.com/595e7759ac930befc21f871a69f8f6c8https://gyazo.com/14aff4a0e0b6855232927832e4039743

What I have tried:

I have the querey statement

I am just not sure how to check if field and radiobuttons have data, and how would I makea string and add to the statement if they have data in the fields.
2 weeks ago