3

I have this table in mysql.

CREATE TABLE `numbering` (
    `numbering_id` INT(11) NOT NULL AUTO_INCREMENT,
    `document_type` VARCHAR(255) NOT NULL,
    `current_no` int(15) NOT NULL DEFAULT '0',
    `next_no` int(15) NOT NULL DEFAULT '1',
    `pattern_name` VARCHAR(255) NULL,
    `created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (`numbering_id`)
);

I add in a record.

insert into numbering (document_type, current_no, next_no, pattern_name) values ('CUST_INV_NUM', 0, 1, 'INV');`

and i try to retrieve a value by doing:

select (pattern_name + '-' + next_no)
from numbering
where document_type = 'CUST_INV_NUM';`

I get value 1 returned. I am expecting INV-1 how do i do it?

3 Answers 3

2

i figured out the answer..

select CONCAT(pattern_name, '-' , next_no) from numbering where document_type = 'CUST_INV_NUM';

Sign up to request clarification or add additional context in comments.

Comments

1

Try using Concat (more info here)

select concat(pattern_name, '-', next_no)
from numbering
where document_type = 'CUST_INV_NUM';

Comments

0

You can also try the below:

    select (pattern_name + '-' + str(next_no))
    from numbering
    where document_type = 'CUST_INV_NUM';

This query returns a string, with output as:'INV-1'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.