简体   繁体   中英

p4sql and concatenation in query statement

I've recently started using p4sql from P4Report, and it's working beautifully except my results are coming back without spaces between fields in a few queries. This is no big deal as long as I can add a character to the end of each field so I can break on that character, but I'm not getting any data back after concatenating chars in between my fields.

Here is an example of a query that works, but leaves spaces out of my results so I cannot split out the different fields per row returned:

            $cmd = "C:\\\"Program Files\"\Perforce\P4Report\p4sql -u test -P 42B3ABC#################### -s \"select client, description, host from clients where description like '%: ".$area."%' \"";
        exec($cmd, $output);

Here is what I'm trying to do to add a char to break on. This works fine in SQL, but not through p4sql, any ideas?

$cmd = "C:\\\"Program Files\"\Perforce\P4Report\p4sql -u test -P 42B3ABC#################### -s \"select client+'||'+description+'||'+host from clients where description like '%: ".$area."%' \"";
        exec($cmd, $output);

The above returns null for every row: Array ( [0] => [1] => (expr) [2] => ====== [3] => NULL [4] => NULL [5] => NULL [6] => NULL [7] => NULL [8] => NULL [9] => NULL [10] => NULL [11] => NULL [12] => NULL)

Figured it out - p4sql uses sql92 syntax. I was 7 years old in 92.

Here is the correct syntax:

$cmd = "C:\\\"Program Files\"\Perforce\P4Report\p4sql -u test -P 42B3ABC#################### -s \"select client||' '||description, host from clients where description like '%: ".$area."%' \"";
    exec($cmd, $output);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM