Let's take a look at the following statement StringsqlStringselect * frompetMessagewherepetNamepet. getPetName (); The preceding statement Selects all the information from the specified information. the left and right sides of getPetName () respectively add one pair of quotation marks to connect the string function, but carefully read the left and right sides of the quotation marks.
Let's take a look at the following statement String sqlString = select * from petMessage where petName = 'Pet. getPetName () '; The preceding statement Selects all the information from the specified information. the left and right sides of getPetName () respectively add one pair of quotation marks to connect the string function, but carefully read the left and right sides of the quotation marks.
Let's first look at the following statement
String sqlString = "select * from petMessage where petName = '" + pet. getPetName () + "';";
The preceding statement Selects all the information from the specified information. getPetName () respectively added a pair of "" to the left and right of the pair to connect to the string function, but carefully looked at the left and right of the pair, there is a symbol 'is the single quotation mark, the single quotation mark is used to enclose pet. the getPetName () Information keeps the SQL statement syntax accurate!