How can I generate a SQL query using SQL :: Abstract?

How to create a sentence WHEREfor this query using SQL :: Summary :

SELECT COUNT (*) FROM table WHERE id = 111 AND NOT FIND_IN_SET (type, '1,2,3,4') AND status = 'pending';

What is the correct way to include conditions like WHERE FIND_IN_SET(type, '1,2,3,4')?

+3
source share
4 answers

See the not_bool parameter :

use SQL::Abstract;

my $sql = SQL::Abstract->new;

my $where = {
    id => 111,
    status => 'pending',
    -not_bool => "FIND_IN_SET(type, '1,2,3,4')",
};

my ($query, @bind) = $sql->select( 
    'table',
    'count(*)',
    $where,
);

Here's what it looks like $query:

SELECT count(*) FROM table WHERE ( ( (NOT FIND_IN_SET(type, '1,2,3,4')) 
AND id = ? AND status = ? ) )
+6
source

This code generates a sentence WHERE:

my $sql = SQL::Abstract->new;    

my %where = (
    id => 111,
    -nest => \"NOT FIND_IN_SET(type, '1,2,3,4')",
    status => 'pending',
);

my ($stmt, @bind) = $sql->where(\%where, \@order);
+3
source

FIND_IN_SET SQL, SQL:: Abstract . SQL SQL:: Abstract. , .

+1

: DALMP

Database abstraction layer for MySQL using PHP

0% fat and extremely easy to use. Connect to the database if necessary.

http://code.google.com/p/dalmp/

-2
source

Source: https://habr.com/ru/post/1769108/


All Articles