For example, the following code, string is a query for the number of boys, girls SQL

public class Test {

    public static void main(String[] args) {
        // Query the number of male and female students
        String sql = "select sex,count(*)" +
                "from student" +
                "group by sex;"; }}Copy the code

If I want to copy the SQL, the general approach is to copy the following first:

"select sex,count(*)" +
                "from student" +
                "group by sex;"
Copy the code

Then delete the double quotes and plus signs to get the desired content

select sex,count(*) from student group by sex;
Copy the code

This is troublesome, but idea is a simpler method

skills

Place the cursor at the value of the String, then press Alt + Enter (Mac is option + Return) and select Copy String Concatenation Text to the Clipboard

Copy the result as follows, it will delete all the “and +, notice it won’t put it on line 1, it will still have 3 rows, but it’s convenient enough.

select sex,count(*)
from student
group by sex;
Copy the code

reference

Copying a concatenated constant to the clipboard

Concatenation – Wikipedia