我有以下查询,我设计用于根据客户端数据从多个视图中编译数据.
SELECT
vw_clients.client_id,
name,
exts,
vms,
ivrs,
queues,
conf10,
conf20,
conf30
FROM
vw_clients,
vw_exts,
vw_vms,
vw_ivrs,
vw_queues,
vw_conf10,
vw_conf20,
vw_conf30
WHERE
vw_clients.client_id = vw_exts.client_id AND
vw_clients.client_id = vw_vms.client_id AND
vw_clients.client_id = vw_ivrs.client_id AND
vw_clients.client_id = vw_queues.client_id AND
vw_clients.client_id = vw_conf10.client_id AND
vw_clients.client_id = vw_conf20.client_id AND
vw_clients.client_id = vw_conf30.client_id;
Run Code Online (Sandbox Code Playgroud)
只要每个视图中有与vw_clients中的记录相关的记录,查询就可以正常工作.但是我需要修改它以使用左连接,以便它返回来自vm_clients的所有记录,并且只返回具有这些客户端记录的其他视图中的记录.
我已经阅读了关于左连接的内容,但最多我只找到了加入一个或两个表的信息 - 但我需要加入8.我是否在vw_clients.client_id上进行左连接到所有的相应client_id字段看法?那是什么语法?
将不胜感激任何帮助.我非常接近解决这个问题,我认为这是这个难题的最后一块!
非常感谢.
我需要检查Perl脚本中是否存在任何一组目录.目录以XXXX*YYY格式命名 - 我需要检查每个XXXX并输入if语句,如果为true.
在我的脚本中,我有两个变量$ monitor_location(包含被扫描的根目录的路径)和$ clientid(包含XXXX).
下面的代码片段已经扩展,以显示我正在做的更多内容.我有一个返回每个客户端ID的查询,然后我为所返回的每个记录循环并尝试计算该客户端ID使用的磁盘空间.
到目前为止我有以下代码(不起作用):
# loop for each client
while ( ($clientid, $email, $name, $max_record) = $query_handle1->fetchrow_array() )
{
# add leading zeroes to client ID if needed
$clientid=sprintf"%04s",$clientid;
# scan file system to check how much recording space has been used
if (-d "$monitor_location/$clientid\*") {
# there are some call recordings for this client
$str = `du -c $monitor_location/$clientid* | tail -n 1 2>/dev/null`;
$str =~ /^(\d+)/;
$client_recspace = $1;
print "Client $clientid has used …
Run Code Online (Sandbox Code Playgroud) 我有一个问题,我试图首先检查文本文件是否存在已知字符串,然后基于此循环该文件并插入不同的行。
由于某种原因,在调用 file.read() 检查测试字符串后,for 循环似乎不起作用。我尝试调用 file.seek(0) 返回到文件的开头,但这没有帮助。
我当前的代码如下:
try:
f_old = open(text_file)
f_new = open(text_file + '.new','w')
except:
print 'Unable to open text file!'
logger.info('Unable to open text file, exiting')
sys.exit()
wroteOut = False
# first check if file contains an test string
if '<dir>' in f_old.read():
#f_old.seek(0) # <-- do we need to do this??
for line in f_old: # loop thru file
print line
if '<test string>' in line:
line = ' <found the test string!>'
if '<test …
Run Code Online (Sandbox Code Playgroud) 我需要在一台机器上安装Python 2.7,从源代码到机器上的现有版本(2.4).我已经成功编译并安装了Python,但是当我尝试运行调用MySQLDB模块的脚本时,它会抛出以下错误:
[root@the-node1 bin]# interactive_recording_archive.py
Traceback (most recent call last):
File "/usr/local/bin/interactive_recording_archive.py", line 8, in <module>
import MySQLdb as mdb
ImportError: No module named MySQLdb
Run Code Online (Sandbox Code Playgroud)
我尝试使用easy-install脚本安装MySQLDB但是无法通过该名称找到任何模块.我安装了MySQL并在机器上工作.
我究竟做错了什么?