我在表格中列出了部件号。
我想在postgresql中返回peroid字符左侧的所有内容。
我的SQL是:
package gameTicTacToe;
import java.util.Arrays;
import java.util.Scanner;
public class GameInput extends printGameBoard {
public static void welcomeMessage(int numberRC) {
System.out.println("\t Welcome to the Tic Tac Toe game \t");
System.out.println("\t Please play and enjoy with -->> 0 and 1 <<-- " + numberRC + " X " + numberRC + " \t\n");
}
public static void initArray(int array[][], int number) {
int row = number;
int column = number;
System.out.println("\n initializing Array with some values : "); // System.out.println("array length : " + array.length); for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[i].length; j++) { constantGameBoard.inputArray[i][j] = 1; } } } public static void main(String[] args) { int input = constantGameBoard.inputForChooseGame(); welcomeMessage(input); initArray(constantGameBoard.inputArray, input); printGameBoard.printArray(constantGameBoard.inputArray, input); UserInput.userInputForGame(input); UserInput.printArray(constantGameBoard.inputArray, input); printGameBoard.printArray(constantGameBoard.inputArray, input); } }
返回以下内容
SELECT item.item_number
FROM public.item;
期望的
item_number
340-1018-000.AAA
340-9922-000.AAB
9400-2007.006
答案 0 :(得分:2)
尝试使用split_part,以便在第一次出现句点字符之前获得部分:
SELECT split_part(item.item_number, '.', 1) as item_number FROM public.item;