Q:

How do you concatenate in DB2 SQL?

A:

Quick Answer

Use the CONCAT function to concatenate together two strings or fields using the syntax CONCAT(expression1, expression2). Though concatenation can also be performed using the || (double pipe) shortcut notation, errors are thrown if DB2 is not configured to allow it.

Know More

Full Answer

  1. Open an SQL command line, and type the CONCAT command

    Open an SQL command line. In the command line type CONCAT. Follow it immediately with an open parenthesis.

  2. Supply the first expression

    Input the first expression. This can be either a string or a field from a table in the database. Follow the first expression with a comma.

  3. Supply the second expression

    After the comma, supply the second expression. As with the first expression, this can be either a string or a field from a table in the database. Follow the second expression with a closed parenthesis.

  4. Execute the command

    Hit the Entry key to execute the command. If both expressions are strings, as with "CONCAT('Hello', 'World')", the output of the command is a single string concatenation of the two, "HelloWorld." If both expressions are fields, as with "SELECT CONCAT(City, State) FROM Locations", the output is a set with all the entries in the first column joined with all the entries in the second column. If one expression is a string and the other a field, as with "SELECT CONCAT(City, 'NY') FROM NYCities", the output is a set with the string expression either prepended or appended to each entry in the given column.

Learn more about Computer Programming

Related Questions

  • Q:

    How do you send SQL queries to MySQL from the command line?

    A:

    The primary option for executing a MySQL query from the command line is by using the MySQL command line tool. This program is typically located in the directory that MySQL has installed. You must have a username and password in order to connect to the MySQL server.

    Full Answer >
    Filed Under:
  • Q:

    What is 2D computer animation?

    A:

    2D computer animation is the technique used to generate two-dimensional images on the digital background of a computer screen. There are several objects that graphic designers use to produce 2D computer animations, which include geometric models, digital photographs and images from flat surfaces such as books and magazines.

    Full Answer >
    Filed Under:
  • Q:

    What is M2M?

    A:

    M2M is an abbreviation for machine to machine. It is a term used to describe technology that allows devices in a network to communicate and act without human input. This technology is typically used for remote inventory monitoring, such as the case of a vending machine.

    Full Answer >
    Filed Under:
  • Q:

    What is J2EE?

    A:

    J2EE stands for Java 2 Enterprise Edition. The Enterprise Edition of Java is used primarily for complex server applications covering multiple facets of business with many different users. The name was changed from J2EE in 2006 to Java EE, and the program is in its seventh iteration as of 2014.

    Full Answer >
    Filed Under:

Explore